_MSVC_LANG有哪些值?

时间:2017-04-26 15:54:39

标签: visual-c++

我正在使用Visual Studio 2015 Update 3,而我的_MSVC_LANG被定义为201402L,无论我是否提供/std:c++14作为编译器参数。

_MSVC_LANG在visual-c ++的后期或早期版本中是否有其他值?

1 个答案:

答案 0 :(得分:3)

Visual Studio 2015之前,_MSVC_LANG宏不存在(内部依赖于包含等效版本号的__cplusplus宏)。

在Visual Studio的yvals.h标题中,您可以看到C ++版本宏的逻辑(这来自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 */

预处理器定义_HAS_CXX17& _HAS_CXX14控制STL功能的包含。