Here are two C compilation units and header files they include:
| main C source | header files |
|---|---|
/* prog1.c */
#undef X
#include "h1.h"
#include "h2.h"
func1() {
}
/* prog2.c */
#define X 1
#include "h1.h"
#include "h2.h"
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 in the following circumstances:
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 for
Precompiled C Headers
Examples of Multiple Initial Sequences for
C Precompiled Headers
![]()
C Compilation
Precompiled C Headers
Organizing Your C Source for
Precompiled Headers
