如何确定VS编译器版本--_MSC_VER || #if _MSC_VER > 1000 #pragma once #endif
2017-08-24 20:29
447 查看
如何确定VS编译器版本
_MSC_VER是MSVC编译器的内置宏,定义了编译器的版本,_MSC_VER 值对应版本关系
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 (Visual Studio 2002)
MSVC++ 6.0 _MSC_VER = 1200
MSVC++ 5.0 _MSC_VER = 1100
example:
#if (_MSC_VER == 1300) //vc7 (Visual Studio 2002)
#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 (Visual Studio 2005)
#import "acax17ENU.tlb" no_implementation raw_interfaces_only named_guids
#elif (_MSC_VER == 1500) //vc9 (Visual Studio 2008)
#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
==================================================================================================================
#if _MSC_VER > 1000
#pragma once
#endif
解释:
这是微软的预编译控制。
在_MSC_VER较小时,它对一些东西的支持与新版不同
_MSC_VER分解如下:
MS:Microsoft(微软)的简写
C:MSC就是Microsoft出的C编译器。
VER:Version(版本)的简写。
全部加在一起就是:Microsoft的C编译器的版本
#pragma once
指示这个文件在编译时只被编译器包括一次!一般用到.h中防止文件被重复包括!
#if _MSC_VER > 1000
是指如果vc编译器的版本大于1000则这个语句被编译!大概小于1000的版本不支持#pragma
once这个语句
很多头文件中有
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
_MSC_VER 定义编译器的版本,VC++6.0就是1200
#if _MSC_VER > 1000的意思就是如果编译器版本高于1000(VC++5.0)
_MSC_VER是MSVC编译器的内置宏,定义了编译器的版本,_MSC_VER 值对应版本关系
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 (Visual Studio 2002)
MSVC++ 6.0 _MSC_VER = 1200
MSVC++ 5.0 _MSC_VER = 1100
example:
#if (_MSC_VER == 1300) //vc7 (Visual Studio 2002)
#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 (Visual Studio 2005)
#import "acax17ENU.tlb" no_implementation raw_interfaces_only named_guids
#elif (_MSC_VER == 1500) //vc9 (Visual Studio 2008)
#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
==================================================================================================================
#if _MSC_VER > 1000
#pragma once
#endif
解释:
这是微软的预编译控制。
在_MSC_VER较小时,它对一些东西的支持与新版不同
_MSC_VER分解如下:
MS:Microsoft(微软)的简写
C:MSC就是Microsoft出的C编译器。
VER:Version(版本)的简写。
全部加在一起就是:Microsoft的C编译器的版本
#pragma once
指示这个文件在编译时只被编译器包括一次!一般用到.h中防止文件被重复包括!
#if _MSC_VER > 1000
是指如果vc编译器的版本大于1000则这个语句被编译!大概小于1000的版本不支持#pragma
once这个语句
很多头文件中有
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
_MSC_VER 定义编译器的版本,VC++6.0就是1200
#if _MSC_VER > 1000的意思就是如果编译器版本高于1000(VC++5.0)
相关文章推荐
- #if _MSC_VER > 1000 #pragma once #endif 作用解释
- #if _MSC_VER > 1000 #pragma once #endif 作用解释
- 关于#if _MSC_VER > 1000 #pragma once #endif
- #if _MSC_VER > 1000 #pragma once #endif 含义
- #if _MSC_VER > 1000 #pragma once #endif 作用解释
- c++/#if _MSC_VER > 1000 #pragma once #endif 作用
- 关于#if _MSC_VER > 1000 #pragma once #endif
- #if _MSC_VER > 1000 #pragma once #endif 作用解释
- #if _MSC_VER > 1000 #pragma once #endif 作用解释
- #if _MSC_VER > 1000 #pragma once #endif
- 如何确定VS编译器版本--_MSC_VER
- #if _MSC_VER > 1000 #pragma once #endif
- #if _MSC_VER > 1000 的含义
- _MSC_VER 编译器的版本
- 判断IE版本的HTML语句详解<!--[if IE]> <![endif]-->
- 判断IE版本的HTML语句详解<!--[if IE]> <![endif]--> - AnswerCard
- <!--[if IE]>….<![endif]-->创建IE各版本专属CSS IE中的if语句
- <!--[if lte IE 8][endif] ]-->IE下判断IE版本的语句
- 通过HTML条件注释判断IE版本的HTML语句详解<!--[if IE]> <![endif]-->
- VS版本记录、_MSC_VER记录