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
The -E option causes gcc to run the preprocessor, display the expanded output, and then exit without compiling the resulting source code.
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.
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.
4. Which gcc option undefines a preprocessor macro? Explanation: None.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With