Once the precompiled initial sequence is created, it can be used in subsequent compiles. Other compilation units can use the precompiled initial sequence under the following conditions:
If the macro was not expanded or tested during the precompile, the status of the macro does not matter, and does not have to match.
Example
Given two compilation units, prog1.c
and prog2.c:
prog1.c prog2.c
----------------------- -------------------------
#undef X #define X 1
#include "h1.h" #include "h1.h"
#include "h2.h" #include "h2.h"
func1() {} func2() {}
h1.h
----------------------
#if TEST
int h1;
#endif
h2.h
----------------------
char h2 = M;
The file prog2.c can use the precompiled header object from prog1.c when:
- TEST has the same definition in both prog1.c and prog2.c, or is not defined in both.
- M has the same definition in both prog1.c and prog2.c, or is not defined in both.
- No additional macros have been defined in prog2.c (whether they are used or not).
The different definitions of X in prog1.c and prog2.c do not matter, since X is never tested or expanded.
![]()
Example of an Initial Sequence