Precompiled Headers? Do we really need them

Todd picture Todd · Jul 16, 2009 · Viewed 9.9k times · Source

Back a long time ago I used to use pre-compiled headers: a. to speed compilation and b. because I supported multiple development tools like CodeWarrior, MPW, VS, ProjectBuilder, gcc, intel compilers, etc, etc.

Now I have a Mac Pro with 32gb of RAM.

Now I use just CMake.

So do we really need pre-compiled headers any more?

Are there obvious benefits that I just dont see/know?

How can one make a cross-platform pre-compiled header? Maybe that would simplify my life too.

Answer

Joris Timmermans picture Joris Timmermans · Jul 16, 2009

There is no such thing as a build that is "Fast enough". Proponents of TDD (Test-Driven Development) will be upset if their build takes longer than a few seconds because it makes turnaround on their development style much slower.

I've worked on projects with hours of compilation time that we halved (or better) by working with pre-compiled headers the right way, so the benefit can be quite large especially for projects that have neglected build times for a while.

However, the preferred solution remains that compilation times never get that far out of hand, by controlling the physical dependencies of the code.

For more information read The Care and Feeding of Pre-compiled Headers