Pre-compiled headers

Heyy, I have a few quick questions regarding pre-compiled header files. Do pch files improve overall program performance or just compilation speed? And while I'm at it, when would you recommend using them?

Thanks!
1. Just compilation speed.
2. No.
closed account (E0p9LyTq)
1. Pre-compiled headers don't effect execution speed of your compiled code, only time needed to compile your code.

2. No. Why?

The time reduced using compiled headers is so small that even projects that can take hours or days to compile the time saved is on the order of a few minutes in my experience.

I've had compile/link problem with pre-compiled headers from time to time that end up costing more time and frustration trying to fix the problems than if I didn't use them.
Last edited on
@FurryGuy
These guys agree. https://qualitycoding.org/precompiled-header/

But it it actually depends (heh heh heh). https://stackoverflow.com/questions/1138301/precompiled-headers-do-we-really-need-them


I personally don’t tend to work on projects so large that dependency hell is an issue.
Thanks for the feedback, I didn't think there'd be people against using pre-compiled headers.
I'm for using pre-compiled headers for headers that are required to be stable;
for a large code base, it can save a significant amount of build time.

For instance, use pre-compiled headers (only) for standard library headers, boost headers etc.
(Clean and rebuild and retest everything if any of these change.)

If (when) support for modules becomes part of core C++, this could become less important.
Last edited on
Topic archived. No new replies allowed.