C language --- translation process, C language ---

Source: Internet
Author: User

C language --- translation process, C language ---

The implementation of c includes two environments:

1. translation environment (translation environment): source program ----> machine commands

2. execution environment (execution environment): execute machine commands

The two environments do not have to be on the same machine.

 

Translation:

The translation will compile the source file into the object code, and then the linker will link each target file together to form an executable file.

The linker also introduces functions of external files called in the program.

Compile:

1. Preprocessing: Processing pseudocommands and special symbols

Pseudocommands include macro-defined commands (# define), Conditional compilation commands (# ifdef, # ifndef, # else, # elif, # endif), header file inclusion commands (# include)

Special symbols: LINE (current number of lines), FILE (name of the source program being compiled), etc.

2. parsing: lexical analysis and syntax analysis to generate the target code

3. Optimization: optimizer optimizes the target file

Commands in unix:

1. gcc (cc) program. c -----> Generate the. out executable file directly. The target file generated in the middle will be deleted after the link.

2. gcc (cc) main. c sort. c lookup. c ----> if more than one file is compiled at a time, the generated target file will not be deleted.

3. gcc (cc) main. c-o main ----> specify the generated file name as main

4. gcc (cc)-c main. c ----> Generate the target file

Related Article

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.