GCC preprocessor output and compilation in one pass

[Origin]: http://stackoverflow.com/questions/9041381/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

shareedit

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.

shareedit
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s