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.
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
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.