I want to use C++17 features.
How can I switch compiling from C++14 to C++17 in Microsoft Visual Studio?
Or is it not available in release versions of VS?
Support for C11 and C17 standards is available in Visual Studio 2019 version 16.8 and later.
The Visual Studio build tools include a C compiler that you can use to create everything from basic console programs to full Windows Desktop applications, mobile apps, and more.
C++17 is a version of the ISO/IEC 14882 standard for the C++ programming language. C++17 replaced the prior version of the C++ standard, called C++14, and was later replaced by C++20.
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)
/std:c++14
/std:c++17
Visual Studio 2022 (MSVC C++20 and the /std:c++20 Switch - C++ Team Blog):
/std:c++20
Any Visual Studio:
/std:c++latest
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://learn.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:
To set this compiler option in the Visual Studio development environment
- Open the project's Property Pages dialog box. For details, see Working with Project Properties.
- Select Configuration Properties, C/C++, Language.
- In C++ Language Standard, choose the language standard to support from the dropdown control, then choose OK or Apply to save your changes.
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:
add_library (${PROJECT_NAME})
set_property (TARGET ${PROJECT_NAME}
PROPERTY
# Enable C++17 standard compliance
CXX_STANDARD 17
)
In the case of an interface library:
add_library (${PROJECT_NAME} INTERFACE)
target_compile_features (${PROJECT_NAME}
INTERFACE
# Enable C++17 standard compliance
cxx_std_17
)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With