__cplusplus expanded minimum values

Viewed 150

Am I right to understand that these are the minimum values of __cplusplus and that C++98 has the same value has C++03?

// C++ 98
#define __cplusplus 199711L
// C++ 03
#define __cplusplus 199711L
// C++ 11
#define __cplusplus 201103L
// C++ 14
#define __cplusplus 201402L
// C++ 17
#define __cplusplus 201500L
// C++ 20
#define __cplusplus 201704L
// looks like the format is YEAR*100+something

Also, does C++20 have an official value now that the standard is released?

1 Answers

Also, does C++20 have an official value now that the standard is released?

It does: 202002L. The format here is a date: YYYYMM (C++20 was made official in February 2020). The value for C++17 was 201703L, not 201500. All the rest are correct (C++03 did not change the __cplusplus macro).

However, this macro is far too coarse to be generally useful. Implementations don't just add every feature in one go, they get added as time progresses. So you're better off using feature-test macros to test for what you actually need.

Related