This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: How to use precompiled header?


Even closer this time.
The B.cpp file only has one line -- #include "B.h"
Instead of using the gch file generated by the g++ command in the make file.
I manually ran:
g++  -fPIC -O -O3 -DUSING_PCH -D_REENTRANT -I"/usr/local/include/boost" 
-I"/usr/local/." -I"/opt/xerces-c-3.1.1/src" -x c++-header A/B.h.gch 
A/B.h

Then, I compiled my own project with "-include A/B.h" in Eclipse, I got
cc1plus: warning: /opt/3rdPartyLib/src/A/B.h.gch not used because A/B.h.gch created with -gnone, but used with -gdwarf-2

Then, I recompiled the gch file with -gdwarf-2, and recompiled my project again, I got:
cc1plus: warning: /opt/3rdPartyLib/src/A/B.h.gch not used because 
`_REENTRANT' is not defined

Then, I recompiled the gch file with -D_REENTRANT, and recompiled my 
project again, I got:
cc1plus: warning: /opt/3rdPartyLib/src/A/B.h.gch not used because 
`__NO_INLINE__' is defined

I just wonder whether there is a simple way to use a precompiled header....

Thanks in advance.




----- Original Message ----
From: Ian Lance Taylor <iant@google.com>
To: Hei Chan <structurechart@yahoo.com>
Cc: gcc-help@gcc.gnu.org
Sent: Wed, June 23, 2010 10:39:07 AM
Subject: Re: How to use precompiled header?

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



      


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]