Get the App
SLTechnology News&Howtos  ›  Development  › 

What is the GCC parameter?

Shulou Source: shulou.com Published: 2022-06-03 05:32:18 11月18日 Update

This article introduces you what the GCC parameters are, the content is very detailed, interested friends can refer to, hope to be helpful to you.

Gcc and Gmail + are gnu's cached compiler gcc/g++, which requires a total of 4 steps to perform the compilation work:

1. Preprocess to generate .i file [preprocessor cpp]

2. Convert the preprocessed file into assembly language to generate the file .s [compiler egcs]

3. There is a file whose assembly is changed into object code (machine code) to generate .o [assembler as]

4. Connect the object code to generate an executable program [linker ld]

Detailed explanation of parameters

-xlanguagefilename

Sets the language used by the file so that the suffix name is invalid and is valid for more than one later. That is, according to the convention, the suffix name of the C language is .c, and the suffix name of C++ is .C or .cpp, if you are very individual, decide that the suffix name of your C code file is .room, then you should use this parameter, which works on the following file name, unless to the use of the next parameter. Are there any parameters that can be used? are there any parameters that can be used as follows: 'cantilevers, grammar, camera, etc.', and 'assembler-with-cpp'.

If you see English, you should be able to understand.

Xnonefilename

Turn off the previous option, that is, let gcc automatically identify the file type based on the file name suffix.

C

Only preprocessing, compilation, and assembly are activated, that is, he only turns the program into obj files

S

Only activate preprocessing and compilation, which means compiling the file into assembly code.

E

Only activate preprocessing, this does not generate a file, you need to redirect it to an output file.

O

Set the target name, by default, the file compiled by gcc is a.out, which sounds terrible, if you agree with me, change it.

Pipe

Using pipes instead of temporary files in compilation may have some problems when using non-gnu assembly tools.

GCC can be used to compile both C programs and C++ programs. Generally speaking, the C compiler determines whether it is a C program or a C++ program by the suffix name of the source file. In Linux, the C source file has the suffix .c, while the C++ source file has the suffix .C or .cpp. However, the gcc command can only compile C++ source files, not automatically connect to the libraries used by C++ programs. Therefore, the C++ + command is usually used to complete the compilation and connection of the C++ program, and the program will automatically call gcc to achieve compilation.

About what the GCC parameters are shared here, I hope the above content can be of some help to you, you can learn more knowledge. If you think the article is good, you can share it for more people to see.

Tags: Files compilers programs suffixes parameters caching preprocessing code generation source files that is time activation target compiler language content names commands more Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information Microsoft Shulou Tech Info Linux Shulou Technology