To test for a feature, cppreference mentions these feature test macros: link.
If the feature is present in the compiler, the macro is defined. But I don't understand why, if defined, they are defined to something like 201606
, which I believe is a version of C++, not of the compiler.
For example, I am using a very recent version of GCC with -std=c++17
for the feature __cpp_lib_hardware_interference_size
. The macro is undefined, which I take to mean GCC doesn't have the feature, despite trying 8.2.1 with the c++17 (and c++2a) switch. In this case, what is the significance of the documented value:
__cpp_lib_hardware_interference_size 201703
(inside the cppreference link)?
Based on cppreference.com, it says:
The following macros expand to a numeric value corresponding to the year and month when the feature has been included in the working draft.
When a feature changes significantly, the macro will be updated accordingly.
So, you can check if the feature exists checking if the macro is defined. Or you can check for the feature version based on the macro value.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With