简体   繁体   English

标识符 wchar_t 未定义

[英]Identifier wchar_t is undefined

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?我了解这些内部类型的定义来自编译器,我正在获取其他类型,但不确定为什么它会特别针对 wchar_t 分崩离析? 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.我怀疑,因为我正在使用Visual Studio 2017 - Clang with Microsoft CodeGen (v141_clang_c2)作为工具集,我怀疑这可能就像打开正确的标志一样简单。

在此处输入图像描述

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.因此,此更改是在了解@keith 告诉我需要为 C 添加 wchat_t 之后进行的。进一步调查以了解编译器级别的行为和可用的标志。 To know why I added the undef of macro please read the below link,要知道为什么我添加了宏的 undef,请阅读下面的链接,

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM