【#ifdef和#def】使用方法

#ifdef和#def两者是共同使用的,中间还可以使用#else作为选择。

#include <IOSTREAM.H>

#define HELLO

extern "C"{
#include <STDIO.H>
};

#ifdef HELLO
int a	=	10;
#else
int a	=	100;
#endif

int main()
{
	printf("%d\n",a);
	return 1;
}

在上述程序中,如果没有#define HELLO那么a的值就是100,有的话那就是10。

猜你喜欢

转载自blog.csdn.net/mce_19/article/details/77333658