This is what I read here: http://gcc.gnu.org/onlinedocs/gcc/Preco ... aders.html
A precompiled header file can be used only when these conditions apply:
* Only one precompiled header can be used in a particular compilation.
* A precompiled header can't be used once the first C token is seen. You can have preprocessor directives before a precompiled header; you can even include a precompiled header from inside another header, so long as there are no C tokens before the #include.
* The precompiled header file must be produced for the same language as the current compilation. You can't use a C precompiled header for a C++ compilation.
* The precompiled header file must be produced by the same compiler version and configuration as the current compilation is using. The easiest way to guarantee this is to use the same compiler binary for creating and using precompiled headers.
* Any macros defined before the precompiled header is included must either be defined in the same way as when the precompiled header was generated, or must not affect the precompiled header, which usually means that they don't appear in the precompiled header at all.
The -D option is one way to define a macro before a precompiled header is included; using a #define can also do it. There are also some options that define macros implicitly, like -O and -Wdeprecated; the same rule applies to macros defined this way.
* If debugging information is output when using the precompiled header, using -g or similar, the same kind of debugging information must have been output when building the precompiled header. However, a precompiled header built using -g can be used in a compilation when no debugging information is being output.
* The same -m options must generally be used when building and using the precompiled header. See Submodel Options, for any cases where this rule is relaxed.
* Each of the following options must be the same when building and using the precompiled header:
* Some other command-line options starting with -f, -p, or -O must be defined in the same way as when the precompiled header was generated. At present, it's not clear which options are safe to change and which are not; the safest choice is to use exactly the same options when generating and using the precompiled header. The following are known to be safe: