IT lexicon › Programming › Precompiled headers

Precompiled headers

Programming På svenska → Updated: 2026-11-13

Binary cache of parsed, type-checked header files — drastically speeds up compilation.

Including `#include <boost/shared_ptr.hpp>` and 50 other Boost headers forces the compiler to parse 100+ kilobytes of C++ per source file. With 200 source files that's 20 megabytes of redundant parsing of the same headers. Precompiled headers (.pch on MSVC, .gch on GCC) store the parsed/type-checked form on disk. Next time that header block matches, the cache is read instead of reparsed.

Can save 30–50% build time on C++ projects with heavy headers. Must regenerate when the header changes (compiler checks timestamps) and is compiler-specific.

← Back to the lexicon