In computer programming, a prefix header is a feature found in some C or C++ compilers used to simplify code and/or to reduce compilation time.
Contents |
In the C and C++ programming languages, a header file is a file whose text is automatically included in another source file by the compiler, usually by the use of compiler directives at the beginning of the source file. A prefix header differs from a normal header file in that it is automatically included at the beginning of every source file by the compiler, without the use of any compiler directives.
Prefix headers are usually pre-compiled in order to reduce compilation times.
On Mac OS X, the Xcode build system generates prefix headers automatically for new projects. A new Cocoa project, for instance, gets a prefix header that looks like this:
#ifdef __OBJC__ #import <Cocoa/Cocoa.h> #endif
As a result, it is unnecessary to explicitly include any of the above files in any Objective-C code in the program, although doing so is harmless, in the case of Objective-C because of the semantics of the #import
directive, but more generally with #include
because of the use of include guards.
Similar prefix headers are generated for other types of project.