C language --- translation process, C language ---
The implementation of c includes two environments:
1. translation environment (translation environment): source program ----> machine commands
2. execution environment (execution environment): execute machine commands
The two environments do not have to be on the same machine.
Translation:
The translation will compile the source file into the object code, and then the linker will link each target file together to form an executable file.
The linker also introduces functions of external files called in the program.
Compile:
1. Preprocessing: Processing pseudocommands and special symbols
Pseudocommands include macro-defined commands (# define), Conditional compilation commands (# ifdef, # ifndef, # else, # elif, # endif), header file inclusion commands (# include)
Special symbols: LINE (current number of lines), FILE (name of the source program being compiled), etc.
2. parsing: lexical analysis and syntax analysis to generate the target code
3. Optimization: optimizer optimizes the target file
Commands in unix:
1. gcc (cc) program. c -----> Generate the. out executable file directly. The target file generated in the middle will be deleted after the link.
2. gcc (cc) main. c sort. c lookup. c ----> if more than one file is compiled at a time, the generated target file will not be deleted.
3. gcc (cc) main. c-o main ----> specify the generated file name as main
4. gcc (cc)-c main. c ----> Generate the target file