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

帅比萌擦擦* 提交于 2019-11-27 17:43:34

问题


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.

How can we tell visual studio environment that we want to compile current code with c99 and c11 C standards.


回答1:


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.

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.

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.

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

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.

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




回答2:


Visual Studio is mostly a C++ compiler. In "C mode", it follows an ancient C standard from 1990.

Around 2013-2015, they made some effort to support not the current, but the previous C standard from 1999 ("C99"), some 16 years after its release. However, the work to conform to this standard has not been completed.

I believe the compiler also supports a few selected features of the current C language ("C11") such as the optional bounds-checking library. This standard has been available for 7 years but is not fully supported.

So if you need a conforming C language compiler, you should look for other alternatives.



来源:https://stackoverflow.com/questions/48981823/is-there-any-option-to-switch-between-c99-and-c11-c-standards-in-visual-studio

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!