I want to use C++17 features.
How can I switch compiling from C++14 to C++17 in Microsoft Visual Studio?
Or it's not avaiable in release versions of VS?
I want to use C++17 features.
How can I switch compiling from C++14 to C++17 in Microsoft Visual Studio?
Or it's not avaiable in release versions of VS?
MSBuild (Visual Studio project/solution *.vcproj/*.sln):
Add to Additional options in Project Settings:
/std:c++latest
to enable latest features - currently C++17 as of VS2017, VS2015 Update 3.https://blogs.msdn.microsoft.com/vcblog/2016/06/07/standards-version-switches-in-the-compiler/
/permissive-
will disable non-standard C++ extensions and will enable standard conformance in VS2017.https://blogs.msdn.microsoft.com/vcblog/2016/11/16/permissive-switch/
EDIT (Oct 2018): The latest VS2017 features are documented here:
https://docs.microsoft.com/en-gb/cpp/build/reference/std-specify-language-standard-version
VS2017 supports:
/std:[c++14|c++17|c++latest]
now. These flags can be set via the project's property pages:CMake:
Visual Studio 2017 (15.7+) supports CMake projects. CMake makes it possible to enable modern C++ features in various ways. The most basic option is to enable a modern C++ standard by setting a target's property in CMakeLists.txt:
In the case of an interface library:
There's now a drop down (at least since VS 2017.3.5) where you can specifically select C++17. The available options are (under project > Properties > C/C++ > Language > C++ Language Standard)
Visual Studio 2015 Update 3 does not support the C++17 feature you are looking for (
emplace_back()
returning a reference).Support For C++11/14/17 Features (Modern C++)
C++11/14/17 Features In VS 2015 RTM
VS 2015 Update 2’s STL is C++17-so-far Feature Complete
Visual Studio 2015 Update 3
STL Fixes In VS 2015 Update 3
If bringing existing Visual Studio 2015 solution into Visual Studio 2017 and you want to build it with c++17 native compiler, you should first Retarget the solution/projects to v141 , THEN the dropdown will appear as described above ( Configuration Properties -> C/C++ -> Language -> Language Standard)