Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio: how to check used C++ platform toolset programmatically

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

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.

like image 388
Serhii Avatar asked Dec 10 '12 02:12

Serhii


1 Answers

I encountered the same problem and added my own preprocessor definition for _MSC_PLATFORM_TOOLSET.
In the project properties in

  • C/C++
  • Preprocessor
  • Preprocessor Definitions

add _MSC_PLATFORM_TOOLSET=$(PlatformToolsetVersion) to make Visual Studio integrate the current Toolset's version to the preprocessor so that your query

#if (_MSC_PLATFORM_TOOLSET > 100)
...
#endif

will finally work.

like image 86
Peopleware Avatar answered Sep 24 '22 07:09

Peopleware