How to use precompiled header?

Ian Lance Taylor iant@google.com
Wed Jun 23 22:11:00 GMT 2010


Hei Chan <structurechart@yahoo.com> writes:

> I think that I am getting close:
>
> cc1plus: warning: /opt/3rdPartyLib/src/A/B.h.gch: not a PCH file
>
>
> B.h.gch is generated by the 3rd party make script.  When I ran the make script, it output something like:
> g++  -fPIC -O -O3 -DUSING_PCH -D_REENTRANT -I"/usr/local/include/boost" -I"/usr/local/." -I"../src" -I"/opt/xerces-c-3.1.1/src" -c -o A/B.h.gch A/B.cpp
>
> Not sure whether it used -o instead of -x causing the problem.
>
> Any suggestion?

That is compiling a .cpp file, not a .h file.  gcc will not generate a
PCH file if you compile a .cpp file, it will generate an object file.

If that .cpp file is really a header file with an unusual name, then
you can use the -x c++-header option to get gcc to generate a PCH.

Ian



More information about the Gcc-help mailing list