How do I turn off Unicode in a VC++ project?

2019-01-05 01:01发布

I have a VC++ project in Visual Studio 2008.

It is defining the symbols for unicode on the compiler command line (/D "_UNICODE" /D "UNICODE"), even though I do not have this symbol turned on in the preprocessor section for the project.

alt text http://i26.tinypic.com/14nz693.jpg

As a result I am compiling against the Unicode versions of all the Win32 library functions, as opposed to the ANSI ones. For example in WinBase.h, there is:

#ifdef UNICODE
#define CreateFile  CreateFileW
#else
#define CreateFile  CreateFileA
#endif // !UNICODE

Where is the unicode being turned on in the VC++ project, how can I turn it off?

7条回答
Melony?
2楼-- · 2019-01-05 01:42

Have you tried: Project Properties - General - Project Defaults - Character Set?

See answers in this question for the differences between "Use Multi-Byte Character Set" and "Not Set" options: About the "Character set" option in visual studio 2010

查看更多
\"骚年 ilove
3楼-- · 2019-01-05 01:44

project properities -> configuration properities -> general -> charater set

查看更多
Lonely孤独者°
4楼-- · 2019-01-05 01:45

you can go to project properties --> configuration properties --> General -->Project default and there change the "Character set" from "Unicode" to "Not set".

查看更多
戒情不戒烟
5楼-- · 2019-01-05 01:50

For whatever reason, I noticed that setting to unicode for "All Configurations" did not actually apply to all configurations.

Picture: Setting Configuragion In IDE

To confirm this, I would open the .vcxproj and confirm the correct token is in all 4 locations. In this photo, I am using unicode. So the string I am looking for is "Unicode". For you, you likely want it to say "MultiByte".

Picture: Confirming changes in configuration file

查看更多
家丑人穷心不美
6楼-- · 2019-01-05 01:50

use #undef UNICODE at the top of your main file.

查看更多
够拽才男人
7楼-- · 2019-01-05 02:03

None of the above solutions worked for me. But

#include <Windows.h>

worked fine.

查看更多
登录 后发表回答