I am trying to build an open-source project and I found that multiple of
identifier wchar_t is undefined error
I understand the definition for these intrinsic types comes from the compiler and I am getting for other types but not sure why it is falling apart for wchar_t specifically? I am suspecting since I am using Visual Studio 2017 - Clang with Microsoft CodeGen (v141_clang_c2) as a toolset I am suspecting this could be just as simple as turning the right flag on.
I added these two lines and it fixed the issue,
#undef _WCHAR_T_DEFINED
#include<stddef.h>
I am however not sure if this is the optimal change.
So this change is after learning what @keith told me that wchat_t needs to be added for C. Investigated further to understand the compiler level behavior and flags available. To know why I added the undef of macro please read the below link,
https://learn.microsoft.com/en-us/cpp/build/reference/zc-wchar-t-wchar-t-is-native-type?view=vs-2019
https://github.com/microsoft/clang-1/blob/master/test/Driver/cl-zc.cpp
In short,
// RUN: %clang_cl /c -### /Zc:wchar_t -- %s 2>&1 | FileCheck -check-prefix=WCHAR_T-ON %s
// WCHAR_T-ON-NOT: argument unused during compilation
// RUN: %clang_cl /c -### /Zc:wchar_t- -- %s 2>&1 | FileCheck -check-prefix=WCHAR_T-OFF %s
// WCHAR_T-OFF: argument unused during compilation
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.