Discussion:
Option to save preprocessor output?
(too old to reply)
Douglas Alan
2007-02-12 18:19:18 UTC
Permalink
Hi. Is there an option to gcc/g++ to tell it to save the preprocessor
output to a file (let's say a ".E" file or something), in *addition* to
doing its normal compilation?

I know about the -E option, but this causes gcc to write the
preprocessor output to stdout, *instead* of generating .o files. On a
project I'm working on, we have a rather complex Makefile arrangement
(actually CMake), and so running "g++ -E" directly on the individual
.cxx file that I want to debug is not so trivial. It would be a lot
more convenient if I could, say, just add an option to CFLAGS, in
addition to "-g", or what have you, and have everything compile
exactly as before, only with the addition that .E files (or whatever)
are written out right next to all the .o files.

|>oug
Petter Gustad
2007-02-12 21:07:45 UTC
Permalink
Post by Douglas Alan
I know about the -E option, but this causes gcc to write the
preprocessor output to stdout, *instead* of generating .o files.
Will this do?

%.e: %.c
$(CC) -E $(CFLAGS) $(CPPFLAGS) $< > $@

Petter
--
________________________________________________________________________
Petter Gustad 8'h2B | ~8'h2B http://www.gustad.com/petter
Douglas Alan
2007-02-13 01:06:17 UTC
Permalink
Post by Petter Gustad
Post by Douglas Alan
I know about the -E option, but this causes gcc to write the
preprocessor output to stdout, *instead* of generating .o files.
Will this do?
%.e: %.c
Not so conveniently because the Makefiles are automatically generated
and updated by CMake. I have been informed, however, that the latest
version of CMake has support for what I want.

Thanks,
|>oug
Andrew Haley
2007-02-13 13:24:29 UTC
Permalink
Post by Douglas Alan
Hi. Is there an option to gcc/g++ to tell it to save the preprocessor
output to a file (let's say a ".E" file or something), in *addition* to
doing its normal compilation?
I know about the -E option, but this causes gcc to write the
preprocessor output to stdout, *instead* of generating .o files. On
a project I'm working on, we have a rather complex Makefile
arrangement (actually CMake), and so running "g++ -E" directly on
the individual .cxx file that I want to debug is not so trivial. It
would be a lot more convenient if I could, say, just add an option
to CFLAGS, in addition to "-g", or what have you, and have
everything compile exactly as before, only with the addition that .E
files (or whatever) are written out right next to all the .o files.
-save-temps does that.

Andrew.

Continue reading on narkive:
Loading...