In any of the implementations of ANSI C, there are two different environments:
translation Environment , in this environment, the source code is converted to executable machine instructions;
Second, the execution Environment , which is used to actually execute the code.
The translation phase consists of several parts:
One, each of the constituent programs (there may be more than one) source files are converted to the target code by the compilation process , respectively.
Each target file is bundled together by a connector (linker) to form a single and complete executable program.
The compilation process is made up of several stages:
One, preprocessor (preprocessor) processing, at this stage, the preprocessor performs some textual operations on the source code. For example, replace the symbol defined by the #define directive with the actual value and read into the contents of the file contained by the #include directive.
Second, the source code after parsing (parse), to determine the meaning of its statement, this stage is to generate the vast majority of error and warning information, and then generate the target code.
The compilation process flowchart is as follows:
The execution phase consists of several parts:
First, the program must be loaded into memory. In a hosting environment (that is, an environment with an operating system), this task is done by the operating system. The uninitialized variables that are not stored in the stack will get the initial value at this time.
Second, the procedure executes. In a hosting environment, typically a small startup program is linked to a program. It handles a range of daily transactions, such as collecting command-line parameters so that programs can access them. The main function is then called to execute the program.
Third, the final stage of program execution is the termination of the program. It can be caused by a variety of different reasons. The "normal" termination is the return of the main function. It may also be terminated by the user by pressing the break key or by the suspension of the phone connection, and may be interrupted by an error during execution.
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
C language Overall operation process