Creating one large precompiled header from multitude of other (possibly also precompiled) headers.

leon zadorin
Tue Apr 5 00:03:00 GMT 2016

On Tue, Apr 5, 2016 at 12:32 AM, Andy Falanga (afalanga)
<> wrote:
> On 03/31/2016 05:12 PM, leon zadorin wrote:
>> Hello and pardon the nativity of question given that I didn't look at
>> the internals of GCC's precompiled header implementation...
>> I am aware that GCC considers a precompiled header file (e.g. x.h.gch)
>> when looking for a usual, included, header file (e.g. #include "x.h").
>> So the question is: when creating one large precompiled header such as
>> all.h.gch where all.h #includes x.h, y.h, z.h, etc. -- will GCC be
>> able to accelerate the process of creating all.h.gch if it sees that
>> x.h itself already has a precompiled version such as x.h.gch?
>> Best regards
>> Leon.
> There are others here who know better than I.  That said, from this link
> to gcc docs:
> , I would say: no.  Consider:
> * Only one precompiled header can be used in a particular compilation.
> This is the very first bullet in the docs when they discuss restrictions.
> Andy

Yes, I've read the docs (albeit not for gcc-4.8.5 as your link
references, as original question was not about specific 4.8 series,
but rather the usual one for 'current' status at -- in the
context of our convo, i.e. that bullet point you mentioned, they would
not differ though, so no harm done).

The main crust of the original question however was whether there was
a subtle difference when they talk about 'particular compilation' --
i.e. between compiling a translation unit (i.e. the usual concept) vs
creating the precompiled header itself (technically yes -- still could
be called a compilation)...

... but even if going by your way of reading docs and taking into
account that point alone (i.e. only one precomp. header in a
compilation) then the process of compiling a given precompiled header
could still use another (even if 1) precompiled header...

Whereas an interesting thing would be to see whether ASTs in pch can
be "incrementally" built-up so to speak... albeit, sadly, I feel the
eventual conclusion would be the same as yours.


More information about the Gcc-help mailing list