_MSVC_LANG Defined as an integer literal that specifies the C++ language standard targeted by the compiler. It's set only in code compiled as C++. The macro is the integer literal value 201402L by default, or when the /std:c++14 compiler option is specified. The macro is set to 201703L if the /std:c++17 compiler option is specified. It's set to a higher, unspecified value when the /std:c++latest option is specified. Otherwise, the macro is undefined. The _MSVC_LANG macro and /std (Specify Language Standard Version) compiler options are available beginning in Visual Studio 2015 Update 3.
https://docs.microsoft.com/en-us/cpp/preprocessor/predefined-macros?view=msvc-160
Consider checking for specific C++ versions/features using both __cplusplus and _MSVC_LANG, so users do not have to remember turning on /Zc:__cplusplus.
MSVC requires
/Zc:__cplusplus
to correctly set__cplusplus
: https://devblogs.microsoft.com/cppblog/msvc-now-correctly-reports-__cplusplus/ However, there is also_MSVC_LANG
:Consider checking for specific C++ versions/features using both
__cplusplus
and_MSVC_LANG
, so users do not have to remember turning on/Zc:__cplusplus
.