The GCC compiler compiler has four stages, preprocessing, compiling, compiling, linking. The preprocessing phase compiles the included header files in the source code, such as Stdio.h, in the compilation phase, when GCC first checks the code for normalization, syntax errors, etc. to determine the actual work to be done by the code, and when the check is correct, GCC translates the code into assembly language, and the assembly phase is generated during the compile phase. S "file into binary target code; The link stage is to link the target file to an executable file.
The function of extern is to tell the compiler to let the variables of the extern declaration pass in the assembly phase (the compiler will give an error to the undefined variable), the variable is defined in another file, and then the variable in the other referenced file is found at the link. This variable must be a global variable in other files. If this variable is defined more than once, an error will occur. And this variable is best not defined in the header file.
52>>extern