Pretreatment have done what?

Introduction: We all know that in order to execute a program, you need to go through several steps: pre-treatment, the compiler, assembler, linker, and then generates an execution document, in front of me an article written about the process of compiling did what to write today look, do what pretreatment process.

 ================= text ========================

Pretreatment process is as follows:

1. header to expand ps #include files into the appropriate position

2. The macro expansion ps expand all the macro and delete #define

3. conditional compilation ps conditions such as pre-compiled instructions: # if, # ifdef, # else

4. Remove the comment ps // / ** / content

5. Add the file name and line number identification

6. Reserved #pragrma ps command instructs the compiler to perform specific actions

In fact, in the final analysis a word, it is to replace the macro command to expand the text.

As the Linux source code, a good deal of use of macros, conditional compilation, header files contain. In fact, not without reason, easy to use macros in programming, high efficiency of program execution. Benefits is conditional compilation may be more compatible across platforms. The header file contains embodies the idea of ​​modular programming.

Following is a brief write a small program to test the effect of pre-compiled

 

 

 

The above program contains header files, macro definitions, pre-compiled, and #pragma command gcc -E test.c> example.i .i redirection of the file, and then open the precompiled code file as follows.

 

 

Then output as follows:

test.c:22:9: note: #pragma message: test demo

 #pragma message("test demo\n")

 

Junior partner found no #pragma message ( "test demo \ n") This is done instructs the compiler to compile-time action, go back and look at the code.

 

Summary: In fact pretreatment is relatively simple, the work done is fixed, this article is simply a rough analyze pretreatment process, after the commissioning process is useful.

 

Old nine Academy members produced

Author: Happy Mirror

Guess you like

Origin www.cnblogs.com/ljxt/p/11579806.html