Why don't set every header file as precompiled ?

Hi there!

I've a quick question about precompiled headers. Why don't set every header file as precompiled in order to reduce compilation time ?

Has a precompiled header any disadvantages ?
Precompiled headers don't get rebuilt, so your build won't know that you changed them.
Has a precompiled header any disadvantages ?
Yes: you can only use it to speed up compilation of code that won't change often (e.g. finished code). Every time code included in the precompiled header changes, the PCH has to be recompiled, and anyone who includes it will also have to be recompiled, obviously.
But if you don't need to keep touching the headers, then by all means include them all in a single PCH and include that in every source file.
jsmith wrote:
Precompiled headers don't get rebuilt, so your build won't know that you changed them.


Yes, they don't get rebuilt (this option ignores them) but my wxDev-C++ IDE (with the MinGW compiler) knows when I changed something in that kind of header and MinGW builds it again...

I don't even have to delete my header.h.pch file...

It's kinda strange...
Last edited on
helios wrote:
Every time code included in the precompiled header changes, the PCH has to be recompiled


And the header file (the one with the .pch extension) has to be deleted before recompiling or it doesn't ?
Either that, or you have to force the compiler to regenerate it.
So the MinGW has to be a great compiler if it regenerates the .pch files without my attention :D ?
GCC doesn't do anything it's not told to do. If the PCH is being regenerated, it's because a tool is telling it to do it.
Yes, I know :P

But according to jsmith:

jsmith wrote:
Precompiled headers don't get rebuilt, so your build won't know that you changed them.


my build option ignores precompiled headers when it doesn't...
Last edited on
Can somebody comment my previous post ?

This wxDevC++'s behaviour keeps nagging me :P
Topic archived. No new replies allowed.