Visual Studio:如何以编程方式检查使用的 C++ 平台工具集 [英] Visual Studio: how to check used C++ platform toolset programmatically

查看:85
本文介绍了Visual Studio:如何以编程方式检查使用的 C++ 平台工具集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须使用 MSVC2012 和 v100 平台工具集(来自 MSVC2010)构建项目.不幸的是,我在代码中使用了 C++11 特性基于范围".我想知道是否有一个预处理器指令可以在编译时了解当前的平台工具集.即

I have to build project using MSVC2012 and v100 platform toolset (from MSVC2010). Unfortunately I'm using C++11 feature "range based for" across the code. I wondering if there is a preprocessor directive that allows to know current platform toolset in compile time. I.e

#if (_MSC_PLATFORM_TOOLSET > 100)
#   define ALLOW_RANGE_BASED_FOR 1
#else
#   define ALLOW_RANGE_BASED_FOR 0
#endif

我尝试使用 _MSC_VER 宏,但对于两个平台工具集,它都设置为 1700(这确实有意义,因为我仍在使用 MSVC2012).我很感激任何建议.谢谢.

I tried use _MSC_VER macro, but for both platform toolsets it is set to 1700 (and this does make sense, because I'm still using MSVC2012). I'd appreciate any suggestion. Thank you.

推荐答案

_MSC_FULL_VER 对于每个平台工具集都是不同的;和 Visual Studio 版本.对于(当前)Visual Studio 2013 预览版,它是 180020617.对于带有 2012 年 11 月编译器 CTP(提供一些 C++11)的 Visual Studio 2012,它是 170060315.和_MSC_VER一样,每个版本的Visual Studio的前4位数字都是一样的;对于 Visual Studio 2012,它们总是 1700.举个例子:

The macro _MSC_FULL_VER is different for each platform toolset; and version of Visual Studio. For the (current) Visual Studio 2013 preview, it is 180020617. For Visual Studio 2012 with the November 2012 Compiler CTP (which gave some C++11), it was 170060315. Like _MSC_VER, the first 4 digits are the same for each version of Visual Studio; for Visual Studio 2012 they are always 1700. Here's an example:

#ifdef _MSC_FULL_VER
  #if   _MSC_FULL_VER == 170060315
  // MSVS 2012; Platform Toolset v110
  #elif _MSC_FULL_VER == 170051025
  // MSVS 2012; Platform Toolset v120_CTP_Nov2012
  #elif _MSC_FULL_VER == 180020617
  // MSVS 2013; Platform Toolset v120
  #endif
#endif // _MSC_FULL_VER

这篇关于Visual Studio:如何以编程方式检查使用的 C++ 平台工具集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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