Reputation: 164
I am using Visual Studio 2015 Update 3 and my _MSVC_LANG
is defined as 201402L
, regardless of whether I supply /std:c++14
as compiler parameter or not.
Does _MSVC_LANG
have other values in later or earlier versions of visual-c++?
Upvotes: 2
Views: 5756
Reputation: 3626
Another resource lists the possible values for _MSVC_LANG
as 201402L
, 201703L
, 202002L
, or a higher unspecified value
, depending on the /std
switch being used during compilation:
_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. The macro is set to 202002L if the /std:c++20 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.
Upvotes: 1
Reputation: 73673
Prior to Visual Studio 2015, the _MSVC_LANG
macro didn't exist (internally they relied on the __cplusplus
macro containing the equivalent version number).
In Visual Studio's yvals.h
header, you can see the logic for C++ version macros (this is from Visual Studio 2017 15.3.3):
#ifndef _HAS_CXX17
#if defined(_MSVC_LANG) && !(defined(__EDG__) && defined(__clang__)) // TRANSITION, VSO#273681
#if _MSVC_LANG > 201402
#define _HAS_CXX17 1
#else /* _MSVC_LANG > 201402 */
#define _HAS_CXX17 0
#endif /* _MSVC_LANG > 201402 */
#else /* _MSVC_LANG etc. */
#if __cplusplus > 201402
#define _HAS_CXX17 1
#else /* __cplusplus > 201402 */
#define _HAS_CXX17 0
#endif /* __cplusplus > 201402 */
#endif /* _MSVC_LANG etc. */
#endif /* _HAS_CXX17 */
The preprocessor definitions _HAS_CXX17
& _HAS_CXX14
control the inclusion of STL features.
Upvotes: 7