5.2.2. C++ compatibility in the GCC Toolset 15
GCC Toolset 15 supports a range of C++ language standards. The default standard is C++17, but you can choose C++98, C++11, C++14, or experimental versions including C++20, C++23, and C++26. Select a different standard with the appropriate compiler flag when building your code.
This compatibility information applies only to GCC from the GCC Toolset 15.
The GCC compiler in the GCC Toolset 15 can use the following C++ standards:
- C++98
- This language standard is available in the GCC Toolset 15. Binaries, shared libraries, and objects built using this standard can be freely mixed regardless of being built with GCC from the GCC Toolset 15, Red Hat Developer Toolset, and RHEL 5, 6, 7, and 8.
- C++11
This language standard is available in the GCC Toolset 15.
Using the C++11 language version is supported when all C++ objects compiled with the corresponding flag have been built using GCC version 5 or later.
- C++14
This language standard is available in the GCC Toolset 15.
Using the C++14 language version is supported when all C++ objects compiled with the corresponding flag have been built using GCC version 6 or later.
- C++17
This language standard is available in the GCC Toolset 15.
This is the default language standard setting for the GCC Toolset 15, with GNU extensions, equivalent to explicitly using option
-std=gnu++17.Using the C++17 language version is supported when all C++ objects compiled with the corresponding flag have been built using GCC version 10 or later.
- C++20, C++23, and C++26
These language standards are available in the GCC Toolset 15 only as experimental, unstable, and unsupported capabilities. Additionally, the compatibility of objects, binary files, and libraries built using these standards cannot be guaranteed.
To enable the C++20 standard, add the command-line option
-std=c++20to yourg++command line.To enable the C++23 standard, add the command-line option
-std=c++23to yourg++command line.To enable the C++26 standard, add the command-line option
-std=c++26to yourg++command line.
All of the language standards are available in both the standard-compliant variant and with GNU extensions.
Use the GCC Toolset 15 for linking when you combine objects built with the GCC Toolset 15 and objects built with the system toolchain, particulary .o or .a files. This ensures any newer library features provided only by the GCC Toolset 15 are resolved at link time.