Precompiled headers issue: -c and -fpch-preprocess should be used together?

Ian Lance Taylor iant@google.com
Wed Apr 7 14:36:00 GMT 2010


Pavel Shevaev <pacha.shevaev@gmail.com> writes:

> Folks, I'm using gcc-4.4.1(4.4.1-4ubuntu9 to be precise) on Ubuntu and
> after trying to make PCH work properly for some time I found that
> precompiled headers are not used if -c option used. Experimenting with
> different options I discovered that it's the -fpch-preprocess option
> which enables PCH in this case.
>
> Is it an expected behavior? If yes, maybe it should be documented here
> http://gcc.gnu.org/onlinedocs/gcc/Precompiled-Headers.html in order to
> save some time for others :)

It is very likely that you are using ccache or distcc.  Those tools
first preprocess the C source code and then compile it.  It's true
that if you are preprocessing, you need to use the -fpch-preprocess
option.  However, -fpch-preprocess is not required if you do not
preprocess, and omitting it should work fine when using gcc proper
rathre than ccache or distcc.

Ian



More information about the Gcc-help mailing list