#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。