2024年6月6日发(作者:)

头文件的“#if _MSC_VER > 1000”

_MSC_VER 是微软预编译控制。在_MSC_VER较小时,它对一些东西的支持与新版不同。

_MSC_VER分解如下: Microsoft的C编译器的版本

MS:Microsoft

C : C编译器。

VER:Version

很多头文件中有

#if _MSC_VER > 1000

#pragma once

#endif

_MSC_VER 定义编译器的版本,VC++6.0就是1200

#if _MSC_VER > 1000 //意思就是如果编译器版本高于1000(VC++5.0)

预处理器指令

#和## 操作符是和#define宏一起使用的,使用# 可以使在#后的首个参

数返回为一个带引号的字符串。

例如, 命令 #define to_string(s) # s 即:碰到to_string(s)都用

#s替代,而#S就是返回带引号的S 将会使编译器把以下命令

cout << to_string(Hello World!) << endl;

理解为 cout << "Hello World!" << endl;

使用##连结##前后的内容. 例如, 命令

#define concatenate(x,y) x##y

int xy = 10;

将会使编译器把

cout << concatenate( x, y ) << endl;

解释为

cout << xy << endl;

理所当然,将会在标准输出处显示'10'.

#define

语法:

#define macro-name replacement-string

#define命令用于把指定的字符串替换文件中的宏名称 . 也就是说,

#define使编译器把文件中每一个

macro-name

替换为

replacement-string

. 替换的字符串结束于行末. 这里是一个经典的

#define应用 (至少是在C中):

#define TRUE 1

#define FALSE 0

...

int done = 0;