C + + source files to the process of running files

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.