Dev Null
Dev Null

Reputation: 4997

The C++ standard versions vs Visual Studio versions

The /std (Specify Language Standard Version) option is available in Visual Studio 2017 and later. Does it mean that previous versions of Visual Studio use particular versions of the C++ standard and, unlike gcc/clang, there's a 1:1 mapping between a VS version and the default C++ standard version provided by the compiler?

Upvotes: 3

Views: 4261

Answers (2)

Shafik Yaghmour
Shafik Yaghmour

Reputation: 158469

There is a blog post Standards version switches in the compiler that explains the introduction of the feature and what MSVC used to do previously:

Traditionally, we would release the compiler in a default mode that combines features striding several versions of the C++ language, e.g. C++98, C++03, C++11, C++14, etc. in addition to conformance improvement bug fixes. This can lead to situations where it is difficult to simultaneously upgrade to the newer and better compiler and at the same time move your code forward. We really appreciate the great feedback you’ve given us about our conformance improvements and new feature work. As the C++ standards committee is gearing up for a new C++ version, we’ve taken the initiative to help you state in your build systems or compiler command lines which version of C++ you are comfortable with while updating to the next version of Visual C++.

Visual C++ has made significant progress towards C++ standards conformance between the first release of Visual Studio 2015 and VS 2015 Update 3. We’ve fixed many issues with constexpr, improved expression SFINAE support, evaluation of initializer lists, variable templates, and more. Our standard library implementation has kept pace with features adopted into the post-C++14 standard draft. And we’ve implemented some major features currently under consideration by the committee, including C++ modules and coroutines. We want you to benefit from all this, but also we want you to consume these features at your own pace, while upgrading to this new update.

All post-C++14 features implemented in this update are off by default; those which were included in previous releases are left on to avoid causing your builds.

...

Upvotes: 3

viraltaco_
viraltaco_

Reputation: 1190

From what I gather /std:c++17 would be equivalent to clang/gcc -std=c++17 argument.

Some versions of msvc may not fully implement some versions of iso C++.

Depending on the Visual C++ compiler version or update level, certain C++14 or C++17 features may not be fully implemented or fully conformant when you specify the /std:c++14 or /std:c++17 options. For example, the Visual C++ 2017 RTM compiler does not fully support C++14-conformant constexpr, expression SFINAE, or 2-phase name lookup.

(cf: https://learn.microsoft.com/en-us/cpp/build/reference/std-specify-language-standard-version?view=vs-2017 )

So that's not exactly a "1:1 mapping between VS version and the default C++ standard version provided by the compiler".

You shouldn't rely on that. Instead you should read the docs for the version of VS you're using.

Hope this answers your question.

Upvotes: 2

Related Questions