How to run c++

王林
王林Original
2019-11-01 15:58:2110099browse

How to run c++

In order for the machine to recognize and run the program, each statement must be converted into a low-level machine language instruction, and then the instructions must be packaged in the format of an executable target program and stored in a binary disk file stored in the form. Taking the C program as an example, the conversion process is roughly divided into four steps: preprocessing, compilation, assembly, and linking.

Detailed steps:

1. The preprocessor modifies the original c program according to the command starting with the character #, and the result is another c program, usually starting with .i as file extension.

2. The compiler translates the text file hello.i into hello.s, which contains an assembly language program.

3. The assembler translates the assembler into machine language instructions, packages these instructions into the format of a relocatable object program, and saves the result in hello.o.

3. In the linking phase, the linker (ld) program is responsible for processing this merging, and the result is a hello file, which is an executable object file and can be loaded into memory and executed by the system.

4. Execute the program. Once the code and data in the target file hello are loaded into main memory, the processor begins executing the main machine language instruction, copying the string from main memory to the register, and outputting it to the screen.

Recommended tutorial: c tutorial

The above is the detailed content of How to run c++. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Related articles

See more