C语言 预处理 编译 汇编 链接
gcc help
$ gcc --help
-save-temps Do not delete intermediate files
-E Preprocess only; do not compile, assemble or link
-S Compile only; do not assemble or link
-c Compile and assemble, but do not link
-o <file> Place the output into <file>
对c文件,想要保留中间文件,执行下面命令:
$ gcc -Wall -save-temps hello.c
// 会生成文件
hello.i
hello.s
hello.o
a.out
下面一一说明。
(1)Pre-processing
-E Stop after the preprocessing stage; do not run the compiler proper. The output is in the form of preprocessed source code, which is sent to the standard output.
Input files that don't require preprocessing are ignored.
预处理的任务是:
- Macro substitution 宏(#define)替换
- Comments are stripped off 删注释
- Expansion of the included files 展开包含文件(#include)的声明
预处理可以理解成:把你所写的源代码转换成扩展的完整源代码。
What the preprocessor does is convert the source code file you write into another source code