include的作用

#include发生在预处理阶段,整个编译链接过程,#include是最简单的了,没有之一。就是在include的位置直接把文件原原本本完完整整一字不落的包含进来,下面举一个极端点的例子:

//file a.c

#include <stdio.h>
int d = 3;
#include "b"

//a.c end

//file b

main(){
printf("d = %d\n",d);

}

//b end

所以include后,源程序变为

//file a.c
#include <stdio.h>
int d = 3;
main(){
printf("d = %d\n",d);

}

猜你喜欢

转载自www.cnblogs.com/saolv/p/9629237.html