Why don't set every header file as precompiled ?

Aug 2, 2010 at 9:57pm
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 ?
Aug 2, 2010 at 10:52pm
Precompiled headers don't get rebuilt, so your build won't know that you changed them.
Aug 2, 2010 at 10:53pm
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.
Aug 3, 2010 at 10:16am
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 Aug 3, 2010 at 10:18am
Aug 3, 2010 at 7:46pm
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 ?
Aug 4, 2010 at 2:45am
Either that, or you have to force the compiler to regenerate it.
Aug 4, 2010 at 1:20pm
So the MinGW has to be a great compiler if it regenerates the .pch files without my attention :D ?
Aug 4, 2010 at 2:30pm
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.
Aug 4, 2010 at 3:38pm
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 Aug 4, 2010 at 3:38pm
Aug 7, 2010 at 8:59pm
Can somebody comment my previous post ?

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