C Language Study Notes (17)

Source: Internet
Author: User

1. Connector

C language has the idea of compiling separately, that is, dividing a C language project into several sources.ProgramLet them compile separately at different times, and then integrate them together at appropriate times. The integration process is completed by the connector.

Most of the time, the connector and compiler are separated, and the connector itself does not understand many C language syntax rules. Because he is generally not in direct contact with C, we think about the C language compilation and running process, the responsibility of the compiler is to translate the C language into a form that the connector can understand.

The connector integrates several target modules generated by the compiler into a load module or an executable file that can be directly executed by the operating system.

The connector also handles naming conflicts. The connector generally regards the target module as a group of external objects. Each external object represents a part of the machine's memory and is identified by an external name. Therefore, when functions and variables are not declared as static, they are regarded as an external object. There are also some compilers that perform special processing on a static declared variable name, and then treat it as an external object.

2. Let's talk about extern.

In fact, extern is also the connector's credit. For example, extern int I; In the connector's opinion, this is a declaration, not a definition. This declaration means that he does not need to allocate space for it, instead, it looks for references to an external object with the same name in other programs.

Therefore, an extern reference must be included in this project. If the program contains two definitions, the general compiler reports an error. The best way is to write the extern definition in a uniform header file. When an external variable is required, reference this header file.

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.