I am using GCC precompiled headers in my project with multi-architecture build, but things break down when I try to place it in a directory different from current source\'s dire
I have found a workaround.
Build a precompiled header under a different name. For example is the header is a.h
, original precompiled header is pchdir.i686/a.h.gch
, build it as
gcc a.h -o pchdir.i686/a-precompiled.h.gch
Use GCC's -include
switch to make sure the renamed header is included before anything else (even before the original a.h
), e.g.
gcc -Ipchdir.i686 -include a-precompiled.h
Final inclusion order in the source file will be: a-precompiled.h.gch
, a.h
, which I've checked with -H
. Original header is included, but is not actually processed because precompiled header has identical include guards (verified as well by inserting an #error
in the original header after building the precompiled one).