/Zc:wchar_t (wchar_t Is Native Type)
wchar_t as a built-in type according to the C++ standard.
If /Zc:wchar_t is on,
wchar_t is a keyword for a built-in integral type in code compiled as C++. If /Zc:wchar_t- (with a minus sign) is specified, or in code compiled as C,
wchar_t is not a built-in type. Instead,
wchar_t is defined as a
unsigned short in the canonical header stddef.h. (The Microsoft implementation defines it in another header that is included by stddef.h and other standard headers.)
We do not recommend /Zc:wchar_t- because the C++ standard requires that
wchar_t be a built-in type. Using the
typedef version can cause portability problems. If you upgrade from earlier versions of Visual Studio and encounter compiler error C2664 because the code is trying to implicitly convert a
unsigned short, we recommend that you change the code to fix the error, instead of setting /Zc:wchar_t-.
The /Zc:wchar_t option is on by default in C++ compilations, and is ignored in C compilations. The /permissive- option does not affect /Zc:wchar_t.
If you write new code that has to interoperate with older code that still uses the
typedef version of
wchar_t, you can provide overloads for both the
unsigned short and
__wchar_t variations of
wchar_t, so that your code can be linked with code compiled with /Zc:wchar_t or code compiled without it. Otherwise, you would have to provide two different builds of the library, one with and one without /Zc:wchar_t enabled. Even in this case, we recommend that you build the older code by using the same compiler that you use to compile the new code. Never mix binaries compiled with different compilers.
When /Zc:wchar_t is specified, _WCHAR_T_DEFINED and _NATIVE_WCHAR_T_DEFINED symbols are defined. For more information, see Predefined Macros.
If your code uses the compiler COM global functions, because /Zc:wchar_t is now on by default, we recommend that you change explicit references to comsupp.lib (either from the comment pragma or on the command line) to either comsuppw.lib or comsuppwd.lib. (If you must compile with /Zc:wchar_t-, use comsupp.lib.) If you include the comdef.h header file, the correct library is specified for you. For information about compiler COM support, see Compiler COM Support.
wchar_t built-in type is not supported when you compile C code. For more information about conformance issues with Visual C++, see Nonstandard Behavior.
To set this compiler option in the Visual Studio development environment
Open the project's Property Pages dialog box. For details, see Set C++ compiler and build properties in Visual Studio.
Select the Configuration Properties > C/C++ > Language page.
Modify the Treat wchar_t as Built-in Type property.
To set this compiler option programmatically
Send feedback about: