1、
1)源代码:
test2.c
#line 1 int main(void){ printf("line 1\n"); printf("line 2\n"); printf("line 3\n"); printf("line 4\n"); printf("line 5\n"); printf("line 6\n"); printf("line 7\n"); printf("line 8\n"); #include "test1.c
?test1.c
?
#line 9 "test2.c" #define LINUX #ifdef WIN32 printf("win32\n"); #elif defined LINUX printf("linux %d %s\n",__LINE__,__FILE__); #else #error no flag define //如果LINUX和WIN32没有定义,#error会显示错误信息,然后停止编译 #endif }
??2)运行结果:
mysea@mysea-pc:~/test$ ./test2
line 1
line 2
line 3
line 4
line 5
line 6
line 7
line 8
linux 13 test2.c