• Uncategorized

About c++ : How-do-you-ensure-C20-support

Question Detail

I have g++ installed on CentOS9

g++ (GCC) 11.2.1 20220127 (Red Hat 11.2.1-9)

I can compile with switch -std=c++20 without errors/warnings.

When I search filesystem for ’11’ I find


But when I search for ’20’ I get nothing.

How do I “install” C++ 20 ? What is it and how can it be done on RH/CentOS ?

Question Answer

11 in the file path is the compiler version, not the C++ version. So it is not a problem that there is no corresponding path with a 20.

If -std=c++20 doesn’t give an error, you have (at least to some degree) C++20 support.

Theoretically there is the __cplusplus macro, which is predefined to a value of at least 202002L for enabled C++20 support, but in practice that doesn’t mean that all C++20 features are supported.

There are further feature-specific feature test macros that may be of help.

For an overview of what exactly is supported in which compiler version see https://en.cppreference.com/w/cpp/compiler_support, as well as the corresponding pages of the individual compilers.

As you can see there, with GCC 11 you have mostly complete C++20 support, except for few items, especially in the standard library, such as for example full module support, constexpr for std::string and std::vector, atomic shared pointers and notably std::format.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.