From source code to executable code

First of all, the overall process must be:

Pre-compilation -> Compile -> Assembly -> Link

1. Pre-compilation

Extend the source code-----is about to insert the command beginning with the character # into the source code and form a file with xxx.i as the suffix

For example,
#include<…> inserts this type of header file into the program text

It can also be expressed from this step

#define is also in pre-compilation

The specific process is to expand all #define macro definitions

But because it is a simple text replacement, if a definition is referenced multiple times, there will be multiple copies in memory

2. Compile

Check the syntax and semantics of the xxx.i file, and finally convert it into assembly language, and generate a file with the suffix xxx.s

const comes into play at this time, that is, constants defined by const must be checked

Constants defined by const have data types and occupy only a piece of memory in memory

Multiple references will not be copied multiple times in memory

It is like creating multiple references in the stack, and all of them point to the piece of memory created in the heap

3. Compilation

Translate the xxx.s file into machine language instructions

That is, from a high-level language to a low-level language-the language understood by the computer

Finally, a file with a suffix of xxx.o is generated---------binary file

4. Link

Assemble the files of each module, such as print and other functions in the standard library provided by the c compiler, merge all templates and generate www files, which can be loaded into memory

Guess you like

Origin blog.csdn.net/qq_43624038/article/details/114437123