How do I check for C++11 support?

There is a constant named __cplusplus that C++ compilers should set to the version of the C++ standard supported see this

#if __cplusplus <= 199711L
  #error This library needs at least a C++11 compliant compiler
#endif

It is set to 199711L in Visual Studio 2010 SP1, but I do not know if vendors will be so bold to increase it already if they just have (partial) compiler-level support versus a standard C++ library with all the C++11 changes.

So Boost’s defines mentioned in another answer remain the only sane way to figure out if there is, for example, support for C++11 threads and other specific parts of the standard.

Leave a Comment