| |||
| Home > Compiler Features > PreCompiled Header (PCH) file processing and the header stop point | |||
The PCH file contains a snapshot of all the code that precedes
a header stop point. Typically, the header
stop point is the first token in the primary source file that does
not belong to a preprocessing directive. In the following example,
the header stop point is int and the PCH file contains
a snapshot that reflects the inclusion of xxx.h and yyy.h:
#include "xxx.h" #include "yyy.h" int i;
The header stop point can be manually specified with #pragma
hdrstop. If used, this pragma must be placed before the
first token that does not belong to a preprocessing directive. In
this example, it must be placed before int, as
follows:
#include "xxx.h" #include "yyy.h" #pragma hdrstop int i;
If a #if block encloses the first non-preprocessor
token or #pragma hdrstop, the header stop point is
the outermost enclosing #if. For example:
#include "xxx.h" #ifndef YYY_H #define YYY_H 1 #include "yyy.h" #endif #if TEST /* Header stop point lies immediately before #if TEST */ int i; #endif
In this example, the first token that does not belong to a
preprocessing directive is int, but the header
stop point is the start of the #if block containing
it. The PCH file reflects the inclusion of xxx.h and,
conditionally, the definition of YYY_H and inclusion
of yyy.h. It does not contain the state produced
by #if TEST.
Compiler Reference: