Categories
技术讨论

VC中Unicode的项目设置

单纯的增加UNICODE,_UNICODE宏,很容易出现链接错误,故笔记如下:

  1. 修改C++\Preprocessor :添加_UNICODE和UNICODE
  2. Link\Output: Entry-Point Symbol 填入指定入口

UNICODE Windows   : wWinMainCRTStartup

UNICODE Console   : wmainCRTStartup

(如果转换会MBCS,若编译错误,则指定入口)

非 UNICODE Windows: WinMainCRTStartup

非 UNICODE Console: mainCRTStartup

如果原先程序为main函数,则需要修改为_tmian。另外如果原先程序中存在__FILE__宏,则出现编译错误,因为__FILE__ 是ANSI字符串,可以如下定义 __WFILE__ :

#define WT2(x) L ## x

#define WT(x) WT2(x)

#define __WFILE__ WT(__FILE__)

2 replies on “VC中Unicode的项目设置”

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.