1:edit编辑器 此时程序员打码;
2:preprocesser预处理器 在预处理阶段,主要处理三类:
- #define
- #include
- #ifdef
#define
1.symbolic constants符号常量 (替换宏)
#define identifier replacement-text
e.g. #define PI 3.1415927 (规定符号常量由大写和下划线组成)
2.macros 和符号常量一样在编译前完成替换
a symbolic constant is a type of macro;
一样是替换,只是可以接受一个或多个参数;
一般建议各级运算都要括号括起来,因为这种替换是文本替换;
use #undef to undefine symbolic constants or macro;
and then a name can be redefined ,or it will throw an error;
文件包含#include
#include <> only search in the pre-defined directories
which means predesigned compiler and system directories
#include “” first search in the same directory as the file to be compiled ,if not find,go to search in the pre-designed compile and system directory;
条件编译conditional compilation
it evaluates a constant integer expression.
Cast expression
,sizeof expression
and enumeration constants
cannot be evaluated in preprocessor directives.
every #if
construct ends with #endif
;
may use #elif
and #else
which is the equivalent of else if
and else
;
可以用来嵌套注释
#if 0
code prevented from compiling
#endif
当然还有如下的
#error token
#pragma
#line
assert()
3.compile编译,主要起到检查sytax error 的作用,生成目标代码;
4.link链接,这里是把各个文件和库的目标代码连接在一起的作用。
注意和include的区别,include是包含头文件,但是函数还是在.c文件里面,靠linker链接在一起。
5loader 把程序读进内存
6cpu执行