问题描述
如何知道 VS2019 编译器支持哪个版本的 C?我查看了项目 C/C++ 和 Linker 命令行,发现没有 -std=Cxx 标志.以下代码编译:
How can I know which version of C is supported by the VS2019 compiler? I looked in the project C/C++ and Linker command lines and found no -std=Cxx flag. The following code compiles:
for (int i = index; i < nb_users - 1; i++) {
users[i] = users[i + 1];
}
所以我猜测根据this,但是有没有办法在 VS2019 的某个地方检查这个?
So I guess it's C99 according to this, but is there a way to check this somewhere in VS2019?
推荐答案
VS2019 支持 ANSI C90 以及 C++ 所需的一些后续标准中的一些其他功能.
VS2019 supports ANSI C90 plus a few other features from a few later standards that are required in C++.
例如,您可以使用此代码判断 MSVC 不完全支持 C99,这将无法编译:
For example, you can tell that C99 is not fully supported in MSVC with this code, which will fail to compile:
int foo(int n, char *s)
{
char s2[n];
strcpy(s2, s);
return !strcmp(s, s2);
}
MSVC 不支持此特定功能(可变长度数组),而您提到的功能(for
循环初始声明)是.
This specific feature (variable-length arrays) is not supported in MSVC, while the feature you mentioned (for
loop initial declaration) is.
这篇关于VS2019 编译器支持哪个版本的 C?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!