Boost logo

Boost-Build :

From: Toon Knapen (toon.knapen_at_[hidden])
Date: 2004-09-03 06:36:25


Vladimir Prus wrote:

> I'd think that header should only include standard headers, not the
> application's headers.

I understand that PCH support is not easy but if it is available, it
should also be able to use precompiled headers for non-system headers
(i.e. application headers) IMO.

>
> Another danger is that if all translation units include the central header,
> which grabs <vector>, <map>, <algorithm> and the like, then the programmers
> might forget to add those include to translation units themself, so with
> "USE_PCH" undefined there will be compile errors. Seems not good for
> cross-platform programming.
>

I also wondered about this so I'm keen to know the answer too.

> 2. gcc
>
> Gcc, too, has two models. You start by compiling a header file. In the first
> model, the compiled header is placed somewhere in include path, and if you
> try to include that header, the precompiled version is used. That is, all
> translation units still have to include a central header. In the second
> model, you add "-include" option to the compiler, which cause it to load the
> header before compiling the translation unit. This is handy, because it avoid
> modifying all translation units. The problem is still that translation unit
> which uses std::vector without include <vector> will compile fine with PCH,
> but won't compile elsewhere.

Anyway, to benefit from PCH, it is best to make a giant header which
includes all headers IIUC (as read in C++ templates of Vandevoorde and
Josuttis). Because a including the same headers but in a different order
results in a different compiler-state.

 


Boost-Build list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk