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

后端 未结 4 2093
轮回少年
轮回少年 2021-02-07 12:44

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 wonderin

4条回答
  •  执念已碎
    2021-02-07 13:09

    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.

提交回复
热议问题