Browse DevX
Sign up for e-mail newsletters from DevX

Tip of the Day
Expertise: Beginner
Feb 13, 2001



Building the Right Environment to Support AI, Machine Learning and Deep Learning

Using Precompiled Headers

Many compilers have a special switch for precompiled headers. A precompiled header is a binary file containing intermediate code that is the result of preprocessing and compiling an ordinary header file. A precompiled header is created the first time the compiler processes an ordinary header file and from then on, instead of compiling that header every time anew, the precompiled header is used. The use of precompiled headers expedites the compilation process considerably because it eliminates the overhead of locating a physical header file, preprocessing all its macro directives, parsing the declarations it contains, instantiating templates, etc. In most cases, the compiler can detect changes in the original header file. When such changes occur, the matching precompiled header is discarded and a new precompiled header replaces it. However, compilers can be fooled easily and as a result, it happens that an out-of-sync precompiled header is still being used. Sometimes the compiler is clever enough to discard an out-of-sync precompiled header, but it does so without generating a replacement. In either case, the remedy is to rebuild the entire project. A full rebuild ensures that all existing precompiled headers are removed from the project and new ones, which are in sync with the current header files, are generated. If you get an error message regarding precompiled headers, rebuild your entire project to ensure that the compiler generates fresh, up-to-date precompiled headers.
Danny Kalev
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date