_MSVC_LANG 可以有哪些值? [英] Which values can _MSVC_LANG have?

查看:22
本文介绍了_MSVC_LANG 可以有哪些值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是 Visual Studio 2015 Update 3 并且我的 _MSVC_LANG 被定义为 201402L,无论我是否提供 /std:c++14code> 作为编译器参数与否.

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.

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

Does _MSVC_LANG have other values in later or earlier versions of visual-c++?

推荐答案

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

Prior to Visual Studio 2015, the _MSVC_LANG macro didn't exist (internally they relied on the __cplusplus macro containing the equivalent version number).

在 Visual Studio 的 yvals.h 标头中,您可以看到 C++ 版本宏的逻辑(来自 Visual Studio 2017 15.3.3):

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 */

预处理器定义 _HAS_CXX17 &_HAS_CXX14 控制 STL 特性的包含.

The preprocessor definitions _HAS_CXX17 & _HAS_CXX14 control the inclusion of STL features.

这篇关于_MSVC_LANG 可以有哪些值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆