Boppity Bop
Boppity Bop

Reputation: 10463

How do you ensure C++20 support?

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

/usr/lib/gcc/x86_64-redhat-linux/11
/usr/include/c++/11
/usr/libexec/gcc/x86_64-redhat-linux/11

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 ?

Upvotes: 0

Views: 3361

Answers (1)

user17732522
user17732522

Reputation: 76698

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.

Upvotes: 3

Related Questions