Visual Studio 2019 社区版能否强制执行严格的 ANSI C 合规性? [英] Can Visual Studio 2019 Community edition enforce strict ANSI C compliance?
问题描述
我正在学习 C 并使用 VS 2019 社区版.
I am learning C and use VS 2019 community edition.
在学习 C 时,我不想意外使用任何 C++ 功能,例如在 for 中声明 for 变量.例如.现在这段代码编译:
While learning C I do not want to use any C++ features accidentally, like declaring the for variable inside the for. E.g. right now this code compiles:
for (int i = 0; i < 100; ++i)
{
...
}
但它不是 C,而是 C++,我希望编译器告诉我这一点.
But it is not C, it is C++ and I wish the compiler to tell me that.
有可能吗?
推荐答案
是的,Visual Studio 通过文件扩展名强制执行 C 编译器.如果它满足 .c,则它切换到使用 C 编译器.没有选项可以说 VS C 编译器应该使用哪个 C 标准.VS 大多符合 C99,并不完全支持最新的 C11.这是因为 VS 编译器是 C++ 编译器,而 C 编程语言支持在阴影中.
Yes, Visual Studio enforces C compiler by file extension. If it meets .c, then it switches to using of C compiler. There is no option to say VS C compiler which C standard should be used. VS mostly conforms to C99, and doesn't fully support the latest C11. It is due to the fact that VS compiler is C++ compiler, and C programming language support is in the shadow.
这是更好的答案 是否可以在 Visual Studio 中在 C99 和 C11 C 标准之间切换?
这篇关于Visual Studio 2019 社区版能否强制执行严格的 ANSI C 合规性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!