Home >Backend Development >C++ >How Can I Check for C 11 Support During Compilation?
C programmers often need to determine if their compiler supports specific features of C 11 to ensure compatibility with their code. Here's how to achieve this:
Some compilers provide a constant named __cplusplus, which indicates the supported C standard version. The following example checks for C 11 support:
#if __cplusplus <= 199711L #error This library needs at least a C++11 compliant compiler #endif
Another option is to use macros from the Boost library, which provides defines for specific C 11 features, such as:
#ifndef BOOST_CXX11_VARIADIC_MACROS #error "Your compiler doesn't support variadic templates." #else template <typename... DatatypeList> class Tuple { // ... } #endif
The above is the detailed content of How Can I Check for C 11 Support During Compilation?. For more information, please follow other related articles on the PHP Chinese website!