Note: I started typing this before Yiannis posted, but I'll just post anyway.
Why was this "Precompiled Headers Strategy" introduced and
why is the default mode "PCH in a directory alongside original header" ?
If you put it in a directory instead of directly next to the header, you can put multiple files in there. This comes in handy for files that are precompiled in different targets (with different compiler options). For instance, in Code::Blocks itself that might just make
sdk/sdk_precomp.h unnecesary: you could add
sdk/sdk.h to the 'sdk' target as well, and the precompiled headers would be
sdk/sdk.h.gch/src and
sdk/sdk.h.gch/sdk. (EDIT: I just ran a diff and
sdk.h doesn't
#include <uservarmanager.h>, the latest addition, so that would have to be added)
i always thought, that gcc does find the *.h.gch only in the same directory where the *.h file resides :?
how can you tell gcc where to look for the PCH file *.h.gch ?
Actually, GCC looks for a gch file or directory in each include directory just before looking for any
#included header. So any header
#included only like <this> (never like "this") you can put the .gch file/dir in any directory in the include path, as long as it's searched before the one the actual header is in (or in the same one, obviously).
The reason you can't do this with headers
#included like "this" is that in that case the current directory is searched first, so if the header is there, then so should the .gch be.
Before Code::Blocks supported precompiled headers, I actually had an extra directory I put in the path that only contained wx/precomp.h.gch and wx/setup.h (which
#defined WX_PRECOMP and then used
#include_next to get the actual setup.h).