我在VS代码中使用了Microsoft的C/C++扩展.我有这样的代码:
#include <stdio.h>
int main() {
bool b;
b = true;
printf("b is %d\n", b);
return 0;
}
VS代码true
分是一个问题,identifier "true" is undefined
分.
我已经正确地设置了我的.vscode/c_cpp_properties.json
文件,以使用最新的C标准(其中定义了true
和false
).
{
"version": 4,
"configurations": [
{
"name": "Mac",
"compilerPath": "/usr/local/Cellar/llvm/17.0.6/bin/clang",
"cStandard": "c23"
}
]
如果我从命令行编译(使用相同的clang),它将在没有警告的情况下构建,并且程序按预期运行.
/usr/local/Cellar/llvm/17.0.6/bin/clang main.c -o main -std=c2x | ./main
你知道我的问题出在哪里吗?我如何才能让VS Code接受true
和false
?