compiler compiler principle of C + + essay

Source: Internet
Author: User

/*

C + + Compiler principle:
1) first understand that declaration and definition are two different concepts
extern int i; Yes declaration, int i; Yes definition
The function is much simpler.
2) compilation is divided into:
Precompiled: Replace macros, include, and other code to copy over
Compiling: Turning code into a machine complaint
Link: the. obj file is typically generated for each CPP file. Here is a detailed explanation
1> Each obj file should contain at least three tables: unknown symbol table, export symbol table, address redefinition table
When the unknown symbol table contains each CPP file itself, obj cannot find the definition of the function or variable, the declaration of the variable is imported into the unknown symbol table.
Export symbol table contains each CPP file variable, function definition, divided into external link symbol and internal link symbol.
Address redirection: Compiles each obj to an EXE file address to ensure the uniqueness of external links
2> The working process of the connector:
First, he will offset all the obj files and then go to the unknown symbol table of all obj files and add the addresses of the symbols of the unknown symbol table by traversing the export symbol table.
Final EXE file generation
3) Each compilation unit is independent, don't worry about declaring it as a duplicate, you should worry about whether the definition will be repeated
4) General external links and the classification of internal link symbols:
Symbols by external linkage: The default global variable function, the member variable function of the class. The static internal member function is defined in the CPP file to worry about his duplicate definition problem
Internally linked symbols: Static,const Decorated members are internal links.
*/

compiler compiler principle of C + + essay

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.