I. Four steps for the program written by C + +, from the source to the executable file, generally through the following four steps:1). preprocessing, generating. ii Files2). Compile, generate assembly file (. s file)3). Assembly that produces the target file (. o or. obj file)4). Link that produces a running file (. out or. exe file) take hello.c as an example. This process can be represented by the following diagram
two. Preprocessingpreprocessing mainly includes the following content:A. Macro expansion for all "#define". B. Process all conditional compilation directives, such as "#if", "#ifdef". "#elif", "#else", "#endif"c. Process "#include" instructions, the process is recursive, that is, the included files may also include other files
d. Remove all gaze "//" and "/**/"E. Adding line numbers and file identifiersF. Keep all of the "#pragma" compiler directivesThe preprocessed. ii file does not include any macro definitions, as all macros have been expanded. The included files have also been inserted into the. ii file.
three. Compiling The process of compiling the pre-processed files is a series of lexical analysis, parsing, semantic analysis and optimization to generate corresponding assembly code files (. s files)
Four. Assembly Assembler is the code that transforms the assembly code into a machine that can run, and each assembly statement almost corresponds to a machine instruction. Finally, the target file (. o or. obj file) is generated.
Five. Links the process of linking consists primarily of address and space allocation (addresses and Storage Allocation), symbol resolution (symbol Resolution), and relocation (relocation)
All rights reserved. Welcome reprint, Reproduced please indicate the source. Thank you
C + + source files to the process of running files