(1). Preprocessing (CPP): There is more than one type of preprocessor, and the preprocessor of C/s is one of the lowest end--lexical preprocessor, which is the simple work of text substitution, macro expansion, and deletion of annotations .
- The GCC-E option can be preprocessed, with the extension. I;
- C + + preprocessing does not do any syntax checking, not only because it does not have syntax checking, but because preprocessing commands do not belong to C/s + + statements (which is why you do not add semicolons when defining macros), and grammar checking is what the compiler does;
- After preprocessing, the only real source code is obtained;
- GCC is really very powerful, if it is VC this IDE, I am afraid I can not see the results after preprocessing.
(2). Compiler (CCL): The text file. I is translated into a text file. s, to get the assembly language program ( high-level languages translated into machine language ), the language program each statement in a standard text format to accurately describe a low-level machine language instructions.
- The GCC-S option can get compiled assembly code with the extension. S;
- Assembly language provides a common output language for different compilers in different high-level languages, for example, the output files produced by the C compiler and the FORTRAN compiler use the same assembly language.
(3). Assembly (AS): translate. s into machine language instructions, package these instructions in a format called relocatable Target program and save the results in the target file. O (The process of translating assembly language into machine language).
- The GCC-C option can be compiled with an extension of. o;
- . O is a binary file whose byte encoding is a machine language instruction instead of a character. If you open the. o file in a text editor, you will see a bunch of garbled characters.
- The working process of translating a source program into a target program is divided into five stages: lexical analysis, grammatical analysis, semantic inspection and intermediate code generation, code optimization, and target code generation . Mainly is the lexical analysis and grammar analysis, also known as the source program analysis, the analysis process found that there are grammatical errors, give the prompt information.
(4). LINK (LD): GCC will go to the system's default search path "/usr/lib" to find, that is, linked to the Libc.so.6 library function . function library is generally divided into static library and dynamic library two kinds . Static library refers to the compilation of links, the library files of the code are all added to the executable file, so the resulting file is relatively large, but at run time also no longer need the library file. The suffix is generally ". a". Dynamic libraries In contrast, when compiling a link does not add the code of the library file to the executable file, but the library is loaded by the runtime link file when the program executes, which can save the system overhead. The general suffix of the dynamic library is named ". So", as described in the previous libc.so.6 is a dynamic library. GCC uses dynamic libraries by default at compile time.
1. Preprocessor, compiler, assembler and linker