What makes a header file precompilable? A header file is precompilable when it is interpreted consistently across different source files. Specifically, when it contains only complete declarations. That is, a declaration in any one file must stand alone as a valid declaration. Incomplete type declarations, such as struct S;, are valid declarations. The complete type declaration can appear in some other file. Consider these example header files:
file a.h struct S { #include "x.h" /* not allowed */ }; file b.h struct T; // ok, complete declaration struct S { int i; [end of file, continued in another file] /* not allowed*/ |
A header file that is incorporated into a precompiled-header file must not violate the following. The results of compiling a program that violates any of these constraints is undefined.
The header file must not use __DATE__ and __TIME__.
The header file must not contain #pragma hdrstop.
A header is also precompilable if it contains variable and function definitions. as well.