Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GCC preprocessor output and compilation in one pass

Is it possible to generate preprocessor output and compilation in one step with GCC?

Something like:

gcc -E -c main.cc -o main.o

that would generate main.o and main.i

like image 950
alesko Avatar asked Jan 27 '12 23:01

alesko


People also ask

What is the gcc option that runs only the preprocessor?

The -E option causes gcc to run the preprocessor, display the expanded output, and then exit without compiling the resulting source code.

How do I create a preprocessed file in gcc?

You can get a preprocessed file in the MSVC environment by defining the value of the 'Generate Preprocessed File' property on the 'C/C++\Preprocessor' tab as shown in Figure 1. To get a preprocessed file using the GCC compiler you need to add the parameters '-E -o file_name.

What is MMD in gcc?

Yet gcc & icc offer a -MMD (or -MD ) option which outputs the names of the header files that the C++ file depends upon. The -MMD dependency option seems to be reliable. If you add a #include to a C file, its timestamp would change so the build system would recompile it.

Which gcc option Undefine a preprocessor macro?

4. Which gcc option undefines a preprocessor macro? Explanation: None.


1 Answers

Yes.

Look at gcc -save-temps option.

It compiles the source file and saves the result of the preprocessing in a .i file. (It also saves the result of the assembler phase to a .s file).

gcc -save-temps -c main.cc -o main.o

will generate main.o but also main.i and main.s.

main.i is the result of the preprocessing.

like image 56
ouah Avatar answered Sep 18 '22 14:09

ouah