Is wchar_t just a typedef of unsigned short?

前端 未结 6 672
滥情空心
滥情空心 2020-12-11 14:54

for example, does:

wchar_t x;

translate to:

unsigned short x;
6条回答
  •  旧巷少年郎
    2020-12-11 15:35

    For anyone else who may come across this answer because function calls in your Visual Studio project won't link, despite both parties taking wchar_t (or a comparable type, such as LPCTSTR with UNICODE #defined), and when you DUMPBIN the library's exports the function takes const unsigned short *, be aware that VS allows you to switch off wchar_t as a built-in type. If someone changes this in a library, and you don't hit the same compiler switch in your project, it will not link.

    This option can be changed under "Project Properties>C/C++/Language/Treat WChar_t as Builtin type", it can also be changed via the "/Zc" option.

提交回复
热议问题