1

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++?

WolfgangS
  • 114
  • 7
  • 10
  • [This](https://blogs.msdn.microsoft.com/vcblog/2016/08/12/stl-fixes-in-vs-2015-update-3/) is probably what you are looking for. – selbie Apr 26 '17 at 16:01
  • 1
    /std:c++14 is the default for Update 3, so adding the option does not change anything. There are no earlier versions that have the macro, we don't have a time machine to guess at later versions. Just try it. – Hans Passant Apr 26 '17 at 17:06

1 Answers1

6

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.

Mark Ingram
  • 68,853
  • 50
  • 168
  • 227