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
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
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).will generate
main.o
but alsomain.i
andmain.s
.main.i
is the result of the preprocessing.No, not with
-E
itself, the-s
,-c
and-E
options are called "stop" options. They actually halt the process at a specific point so you can't keep going.If you want to do that, you have to do it in two passes, or use
-save-temps
to keep copies of the temporary files normally deleted during compilation.From the
gcc
manpage, stuff discussing-E
(slightly paraphrased):And a description of
-save-temps
: