How MS Visual Studio updates the language SDKs? - c++

I was wondering, the new language features added in C++, are available in old versions of Microsoft Visual Studio? How VS versions update the language SDKs?

No, the new C++11 features which are added to the compiler are only in the newest version. Even the latest verions [VS2012] doesn't currently support all of C++11 yet though - see here for the list
Some parts of C++11 (previously called TR1 and then into C++0x) were added to VS2010 at the time - std::shared_ptr, unordered associative containers, etc.
[Disclosure - I work for MS but have nothing to do with the compiler team, answer is from public sources only]

Related

Visual Studio 2019 - force C++11 features only

I use Visual Studio 2019 for C++ development. Due to constraints of legacy systems that code will be deployed to, I am limited to using only C++11 language features (specifically GCC 4.8.5).
The default in VS2019 is C++14, which is obviously a super set of C++11. I can't see a way to specify C++11 only. This would be useful as a much faster way to see if I accidentally include newer C++ features than seeing things fail in the build system.
Is there any way to change this setting?
I am afraid it's not possible.
there is no plan to add a C++11 switch
Link: Standards version switches in the compiler
The compiler doesn't support standards options for C++98, C++03, or
C++11.
/Zc:__cplusplus

How to compile with VS2017 for an older C++ standard?

I am using Visual Studio 2017 and need to create code that is compatible to VS2008 (C++03 or C++98). Is there a switch to restrict MSVC to C++03 features?
I am using CMake and tried to set
set_property(TARGET tgt PROPERTY CXX_STANDARD 98)
But this seems only to make sure, that the compiler supports C++98 or newer.
Any solution, that checks if C++ code uses features that are newer than the features supported by VS2008 will work as well. I just need to make sure, that I do not accidentally use features that are too new.
MSVC only got the standard switch in one of the updates to VS2015 (Update 3 to be exact) which was more or less C++14 compliant, and as such there are only switches for standards starting with C++14 (plus a few later features that were already implemented at the time of the update). All older features are enabled unconditionally for backwards compatibility (and because of all the work required to retrofit already implemented features for previous standards for virtually no gain).
See this blog post for more information: https://devblogs.microsoft.com/cppblog/standards-version-switches-in-the-compiler/
Also, note that there were a lot of conformance improvements in newer versions of MSVC, so even with the std switches you could write code that wouldn't work or would behave differently on older compiler.
A better solution would be just to use VS2008 toolset from VS2017 visual studio, as explained here: https://devblogs.microsoft.com/cppblog/stuck-on-an-older-toolset-version-move-to-visual-studio-2015-without-upgrading-your-toolset/
That way you'll be certain your code compiles on the older toolset, while using up-to-date IDE.

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

Which C++ versions are supported by specific Visual Studio versions?

Which Visual Studio Version support C++11, C++14 or C++17?
I assume, that some version do support not all functions, but the question is aimed at the core functions.
Are there any differences between the Community Versions concerning the supported C++ version?
Thanks.
I find that this page should answer your question.
As for the Community Version, it supports the same C++ version as the other versions. The difference is in the tool provided(profiler, static analysis, etc.).
That’s a bit of a tricky question. For GCC/libstdc++ and Clang/libc++ the answer is usually pretty clear along the lines of: “Full support for all C++XX language and library features starting from version X.Y”.
But MSVC even in the very latest version does not have full support for C++11. On the other hand it already has a lot of the features from C++14 and even the upcoming C++17. So the question you’ll have to answer is: Which features do I want/need and from which version are they available? The links from the other question and its comments are a good starting point for this:
Support For C++11/14/17 Features (Modern C++)
Visual C++ Team Blog: C++17 Features In Visual Studio 2017 Version 15.3 Preview. There may be new versions of this blog post for newer VS versions as they are released. Look for posts by Stephan T. Lavavej to find the latest one. He is the maintainer of Microsoft’s standard library implementation.
As a rule of thumb I recommend you always go with the very latest version you can get your hands on. And if that’s not possible you probably don’t want to go older than VS 2015.
Microsoft constantly closes more and more of those older holes in their implementation. So probably and hopefully by C++20 or C++23 the situation will be similar to Clang or GCC.

How to find what's new in VC++ v10?

Googling nor binging "VC++ What's new C++0x" gives me nothing that tells me what is new.Is there an official page at msdn or something similiar that contains the information for VC++ 10? I've seen such for C#,there must be one for what I'd enjoy to read.
If not, please list the new features available in Visual Studio 2010 for VC++.
The Visual C++ Team Blog has frequent articles about what's new for VC++ in Studio 2010. It's not an exhaustive list, but does detail many of the new additions.
There's also an MS site which lists some of whats new.
Wikipedia's Visual C++ page has a recap, which I imagine will be updated frequently as we get closer to the release:
Visual C++ 2010 (known also as Visual
C++ 10.0) is planned for release on
April 12, 2010. It is currently in
development, and available publicly
only in the form of beta version, and
available on MSDN as a release
candidate. The Visual C++ team is
considering using a SQL Server Compact
database to store information about
the source code, including
IntelliSense information, for better
IntelliSense and code-completion
support. This version adds a
modern C++ parallel computing library
called the Parallel Patterns Library,
partial support for C++0x,
significantly improved IntelliSense,
and performance improvements to both
the compiler and generated code.
This version is built around .NET 4.0,
but supports compiling to machine
code. The partial C++0x support in
VC10 consists of 6 compiler features
(lambdas, rvalue references, auto,
decltype, static_assert, nullptr), and
some library features (e.g. moving the
TR1 components from std::tr1 namespace
directly to std namespace). Variadic
templates were also considered, but
delayed until some future version due
to lower priority which stemmed from
the fact that unlike other
costly-to-implement features in VC10
(lambda, rvalue references), this one
would benefit rather the minority of
library writers than the majority of
compiler end users.
Beta 2 version number: 16.00.21003.01 (this is the version of compiler; the IDE itself has version number 16.00.21006.01)
RC version number: 16.00.30128.01