在 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 编写简单的程序并使用 c99
和 c11
标准编译.在 Visual Studio 中,我只能找到 C++ 标准的编译器开关.
I am new to Visual Studio Environment and I am using VS2017 Pro.
I wanted to write simple program in C and compiled with both c99
and c11
standards. In Visual Studio, I could only find compiler switches for C++ standards only.
我们如何告诉 Visual Studio 环境我们要使用 c99
和 c11
C 标准编译当前代码.
How can we tell visual studio environment that we want to compile current code with c99
and c11
C standards.
推荐答案
Visual C++ 支持的唯一模式"是:/std:c++14
符合 C++14 的模式(默认),/std:c++17
支持 C++17 的模式,在 VS 2017 (15.6) 中还不是很完整.还有一个 /std:c++latest
模式,在未来的某个时间点将包含 C++20 中的内容.所有这些都应与 /permissive-
结合以提高一致性.
The only 'modes' supported by Visual C++ are: /std:c++14
mode for C++14 conformance (the default), /std:c++17
mode for C++17 support which is not quite complete as of VS 2017 (15.6). There is also a /std:c++latest
mode which at some future point will include things in C++20. All of these should be combined with /permissive-
for improved conformance.
为了满足 C++11 标准库一致性,Visual C++ 必须支持 C99 标准库,这与支持 C99 语言一致性不是一回事.
To meet C++11 Standard Library conformance, Visual C++ has to support the C99 Standard Library, that's not the same thing as supporting C99 language conformance.
在某些时候,为了满足 C++17 标准库的要求,Visual C++ 将不得不支持 C11 标准库,这与 C11 语言一致性不同.
At some point to meet C++17 Standard Library requirements, Visual C++ will have to support the C11 Standard Library and again that's not the same thing as C11 language conformance.
请参阅 Microsoft 的 C++ 标准一致性 和 C++11/14VS 2013 中的 STL 功能、修复和重大更改
MSVC 帖子中有一个评论线程:Windows 的最佳选择,其中 Visual C++ 项目经理负责解决真正的C11"一致性问题.
There is a comment thread in the post MSVC: The best choice for Windows where a Visual C++ project manager takes on the question of true 'C11' conformance.
奥努尔,
虽然我们首先关注的是 C++ 一致性,但我们关注的是 C 一致性.
我们在 VS 2013 中做了一些关于 C 一致性的工作,虽然我们没有公开它很多.该工作包括:
– C99 _Bool
– C99 复合文字
– C99 指定初始值设定项
– C99 变量声明
我们的 C++ 一致性工作即将结束.最后的项目之一是符合标准的预处理器:C 和 C++ 共享的功能.这预处理器也将标志着我们的 C 一致性推送的开始作为我们 C++98/11/14 一致性工作的结束.
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.
安德鲁
更新: VS 2019 (16.8) 将包括 /std:c11
和 /std:c17
标准开关.请参阅这篇博文.因为 MSVC 编译器不支持可变长度数组 (VLA),所以它不声明符合 C99.请注意,这些开关启用了 这篇博文.
UPDATE: VS 2019 (16.8) will include /std:c11
and /std:c17
standards switches. See 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 中是否有在 C99 和 C11 C 标准之间切换的选项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!