在 Visual Studio 中是否有任何选项可以在 C99 和 C11 C 标准之间切换?

Is there any option to switch between C99 and C11 C standards in Visual Studio?

我是 Visual Studio 环境的新手,我正在使用 VS2017 Pro。 我想用 C 编写简单的程序并使用 c99c11 标准编译。在 Visual Studio 中,我只能找到 C++ 标准的编译器开关。

我们如何告诉 visual studio 环境我们要使用 c99c11 C 标准编译当前代码。

Visual C++ 唯一支持的 'modes' 是:/std:c++14 符合 C++14 的模式(默认),/std:c++17 不支持 C++17 的模式截至 VS 2017 (15.6) 非常完整。还有一个 /std:c++latest 模式,它在未来的某个时候将包含 C++20 中的内容。所有这些都应与 /permissive- 结合使用以提高一致性。

为了满足 C++11 标准库一致性,Visual C++ 必须支持 C99 标准库,这与支持 C99 语言一致性不是一回事。

在某些时候,为了满足 C++17 标准库的要求,Visual C++ 必须支持 C11 标准库,这与 C11 语言一致性不是一回事。

C++ Standards Conformance from Microsoft and C++11/14 STL Features, Fixes, And Breaking Changes In VS 2013

在 post MSVC: The best choice for Windows 中有一个评论线程,其中 Visual C++ 项目经理提出真正 'C11' 一致性的问题。

Hi Onur,

C conformance is on our radar though we’re focusing on C++ conformance first.
We did some work in VS 2013 on C conformance, though we didn’t publicize it a lot. That work included:
– C99 _Bool
– C99 compound literals
– C99 designated initializers
– C99 variable declarations
We’re nearing the end of our C++ conformance work. One of the last items is a conforming preprocessor: a feature shared by C and C++. The preprocessor will mark the beginning of our C conformance push as well as the end of our C++98/11/14 conformance work.

Andrew

更新: VS 2019 (16.8) 将包括 /std:c11/std:c17 标准开关。参见 this blog post. Because the MSVC compiler does not support Variable-length Arrays (VLA) it does not claim C99 conformance. Note that these switches enable the new C99 preprocessor covered in this blog post

Visual Studio 主要是一个 C++ 编译器。在 "C mode" 中,它遵循 1990 年的古老 C 标准。

在 2013-2015 年左右,他们做出了一些努力来支持 1999 年 ("C99") 发布的前一个 C 标准,而不是当前的 C 标准,距它发布大约 16 年。但是,符合该标准的工作尚未完成。

我相信编译器还支持当前 C 语言 ("C11") 的一些选定功能,例如可选的 bounds-checking 库。该标准已经推出 7 年,但并未得到完全支持。

因此,如果您需要符合标准的 C 语言编译器,您应该寻找其他替代方案。