#include 是一个预处理指令,作用是寻找指令后面<>或“”中的文件名,并把这个文件的内容包含到当前的文件中,被包含的文件中的文本将替换源代码文件中的#include指令。
注意:#include 后面也可以不是头文件。
如:
// test.h int a = 2;
// test.txt 1235678
// main.c
#include "test.h"
#inlcude "test.txt"
int main()
{
return 0;
}
gcc -E main.c -o main.txt 预编译,查看main.txt:
# 1 "main.c" # 1 "" # 1 " " # 1 "main.c" # 1 "test.h" 1 int a = 3; # 2 "main.c" 2 # 1 "test.txt" 1 1234 # 3 "main.c" 2 int main() { return 0; }



