Question:
How can you determine at compile-time whether your compiler supports specific features of the C 11 standard?
Answer:
One reliable method is to use the __cplusplus constant, which C compilers should set to reflect the version of the standard they support. For example:
#if __cplusplus <= 199711L #error This library needs at least a C++11 compliant compiler #endif
This code will generate an error if the compiler's C version is less than or equal to 199711L, indicating that C 11 support is not available.
However, some vendors may not update __cplusplus immediately after implementing partial C 11 support. In such cases, using Boost's defines is still recommended for granular detection of specific C 11 features.
The above is the detailed content of How Can I Check for C 11 Compiler Support at Compile Time?. For more information, please follow other related articles on the PHP Chinese website!