Eric's Blog

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

MSC_VER 定义编译器的版本。下面是一些编译器版本的_MSC_VER值(参见扩展阅读中的参考文献2的链接)

MSVC++ 12.0 _MSC_VER == 1800 (Visual Studio 2013)
MSVC++ 11.0 _MSC_VER == 1700 (Visual Studio 2012)
MSVC++ 10.0 _MSC_VER == 1600 (Visual Studio 2010)
MSVC++ 9.0  _MSC_VER == 1500 (Visual Studio 2008)
MSVC++ 8.0  _MSC_VER == 1400 (Visual Studio 2005)
MSVC++ 7.1  _MSC_VER == 1310 (Visual Studio 2003)
MSVC++ 7.0  _MSC_VER == 1300
MSVC++ 6.0  _MSC_VER == 1200
MSVC++ 5.0  _MSC_VER == 1100

 

//******************************************************************************
// Automated platform detection
//******************************************************************************

    // _WIN32 is used by
    // Visual C++
    #ifdef _WIN32
    #define __NT__
    #endif

    // Define __MAC__ platform indicator
    #ifdef macintosh
    #define __MAC__
    #endif

    // Define __OSX__ platform indicator
    #ifdef __APPLE__
    #define __OSX__
    #endif

    // Define __WIN16__ platform indicator
    #ifdef _Windows_
    #ifndef __NT__
    #define __WIN16__
    #endif
    #endif

    // Define Windows CE platform indicator
    #ifdef WIN32_PLATFORM_HPCPRO
    #define __WINCE__
    #endif

    #if (_WIN32_WCE == 300) // for Pocket PC
    #define __POCKETPC__
    #define __WINCE__
    //#if (_WIN32_WCE == 211) // for Palm-size PC 2.11 (Wyvern)
    //#if (_WIN32_WCE == 201) // for Palm-size PC 2.01 (Gryphon) 
    //#ifdef WIN32_PLATFORM_HPC2000 // for H/PC 2000 (Galileo)
    #endif

 example2:

    #if (_MSC_VER == 1300)  //vc7

    #import "acax16ENU.tlb" no_implementation raw_interfaces_only named_guids

    #elif (_MSC_VER == 1200)  //vc6

    #import "acad.tlb" no_implementation raw_interfaces_only named_guids

    #elif (_MSC_VER == 1400) //vc8

    #import "acax17ENU.tlb" no_implementation raw_interfaces_only named_guids

    #elif (_MSC_VER == 1500) //vc9

    #import "acax18ENU.tlb" no_implementation raw_interfaces_only named_guids

    #endif

在程序中加入_MSC_VER宏可以根据编译器版本让编译器选择性地编译一段程序。例如一个 版本编译器产生的lib文件可能不能被另一个版本的编译器调用,那么在开发应用程序的时候,在该程序的lib调用库中放入多个版本编译器产生的lib文 件。在程序中加入_MSC_VER宏,编译器就能够在调用的时根据其版本自动选择可以链接的lib库版本,如下所示。

#if _MSC_VER >= 1400 // for vc8, or vc9
#ifdef _DEBUG
#pragma comment( lib, "SomeLib-vc8-d.lib" )
#else if
#pragma comment( lib, "SomeLib-vc8-r.lib" )
#endif
#else if _MSC_VER >= 1310 // for vc71
#ifdef _DEBUG
#pragma comment( lib, "SomeLib-vc71-d.lib" )
#else if
#pragma comment( lib, "SomeLib-vc71-r.lib" )
#endif
#else if _MSC_VER >=1200 // for vc6
#ifdef _DEBUG
#pragma comment( lib, "SomeLib-vc6-d.lib" )
#else if
#pragma comment( lib, "SomeLib-vc6-r.lib" )
#endif
#endif

 

posted on 2015-09-19 11:20  ericsure  阅读(1967)  评论(0编辑  收藏  举报