/*
C + + Compiler principle:
1) first understand that declaration and definition are two different concepts
extern int i; Yes declaration, int i; Yes definition
The function is much simpler.
2) compilation is divided into:
Precompiled: Replace macros, include, and other code to copy over
Compiling: Turning code into a machine complaint
Link: the. obj file is typically generated for each CPP file. Here is a detailed explanation
1> Each obj file should contain at least three tables: unknown symbol table, export symbol table, address redefinition table
When the unknown symbol table contains each CPP file itself, obj cannot find the definition of the function or variable, the declaration of the variable is imported into the unknown symbol table.
Export symbol table contains each CPP file variable, function definition, divided into external link symbol and internal link symbol.
Address redirection: Compiles each obj to an EXE file address to ensure the uniqueness of external links
2> The working process of the connector:
First, he will offset all the obj files and then go to the unknown symbol table of all obj files and add the addresses of the symbols of the unknown symbol table by traversing the export symbol table.
Final EXE file generation
3) Each compilation unit is independent, don't worry about declaring it as a duplicate, you should worry about whether the definition will be repeated
4) General external links and the classification of internal link symbols:
Symbols by external linkage: The default global variable function, the member variable function of the class. The static internal member function is defined in the CPP file to worry about his duplicate definition problem
Internally linked symbols: Static,const Decorated members are internal links.
*/
compiler compiler principle of C + + essay