How to manage C++ standard [EXPERIMENTAL]¶
This is an experimental feature subject to breaking changes in future releases.
Previously, it was implemented as a first level setting
cppstd, we encourage
you to adopt the new subsetting and update your recipes if they were including the
deprecated one in its settings attribute.
The setting representing the C++ standard is
The detected default profile doesn’t set any value for the
The consumer can specify it in a profile or with the
conan install . -s compiler.cppstd=gnu14
As it is a subsetting, it can have different values for each compiler (also, take into account that depending on the version of the compiler the standard could have only partial support and may change the ABI).
Valid values for
|20||C++ 20 (Still C++20 Working Draft)|
Valid values for other compilers:
|gnu98||C++ 98 with GNU extensions|
|gnu11||C++ 11 with GNU extensions|
|gnu14||C++ 14 with GNU extensions|
|gnu17||C++ 17 with GNU extensions|
|20||C++ 20 (Partial support)|
|gnu20||C++ 20 with GNU extensions (Partial support)|
The value of
compiler.cppstd provided by the consumer is used by the build helpers:
- The CMake build helper will set the
CONAN_CMAKE_CXX_EXTENSIONSdefinitions that will be converted to the corresponding CMake variables to activate the standard automatically with the
- The AutotoolsBuildEnvironment build helper will adjust the needed flag to
- The MSBuild/VisualStudioBuildEnvironment build helper will adjust the needed flag to
CLenv var automatically.
By default Conan will detect the default standard of your compiler to not generate different binary packages.
For example, you already built some
gcc 6.1 packages, where the default C++ standard is
If you introduce the
compiler.cppstd setting in your profile with the
gnu14 value, Conan won’t generate
new packages, because it was already the default of your compiler.
Check the package_id() reference to know more.
Conan 1.x will also generate the same packages as the ones generated with the deprecated
cppstd for the default value of the standard.
When the package to be built requires a minimal C++ standard support (e.g. 17), it can be done by
cppstd. For such condition, there is the helper check_min_cppstd.