1. precompilation: Primary processing of the pre-compiled instructions in the source file starting with #. (The precompiled. I file does not contain any macro definitions, because all macros have been expanded and the included files have been inserted into the. i file)
- Delete all # define, and expand all macro definitions
- Handles all conditional precompiled directives, such as: #if, #ifdef
- Handles the # include precompiled directives, inserting the contained files into the location of the precompiled instruction
- Delete all comments
- Add line numbers and file name identifiers to facilitate compile-time compiler-generated line number information for debugging and to display line numbers when compiling error messages or alarms at compile time
- Keep all #pragma compiler directives for the compiler to use them.
2. Compiling: The compilation process is the pre-processed files for a series of lexical analysis, grammar analysis, semantic analysis and optimization of the corresponding assembly code files.
3. Assembler: A assembler is a command that transforms assembly code into a machine executable, with almost every assembly statement corresponding to a machine instruction. So the assembly process is relatively simple, it does not have a complex syntax, there is no semantics, and do not need to do instruction optimization, just according to the assembly instructions and machine instructions one by one translation of the table can be.
4. link : After a program is divided into multiple modules, how these modules are combined into a single program is a problem that needs to be addressed. The problem of how to combine the modules can be attributed to the problem of how to communicate between the modules, the most common is the static language of C + +, there are two ways of communication between modules, one is the function call between modules, and the other is variable access between modules. function access needs to know the address of the target function, and variable access needs to know the address of the target variable, so these two ways can be attributed to the reference to the symbol between the modules. The splicing process of this module is the connection.
In fact, the linker is to put some instructions on the other symbolic address of the reference to correct. Link process cavities include address and space allocation, symbolic resolution and relocation, etc.
Self-cultivation of programmers-compiling and linking