2 ms·
I think that's (a big part) of the whole point: splitting a project into too many small headers which depend on each other is bad. Including headers into header
by flohofwoe 6y ago
I think that's (a big part) of the whole point: splitting a project into too many small headers which depend on each other is bad. Including headers into headers just hides the problem, but it's still there under the hood and grows worse the bigger the project becomes until it's too late to do anything about it. That how you get hours-long compile times in large C++ projects.
Instead use few big headers, for instance one public-interface header per system/module which only contains declarations (no inline or template code), and at most one private header for each module (or better none at all). Then keep the dependency tree between modules/systems as flat as possible.
This is especially important for large projects.
- guenthert 6y agoThe preprocessor can be expected to read files and scan to the corresponding #endif very fast. Reading from cache is also very fast. C++ compilation bogs down when templates are involved. You want to split those (in a way which makes sense to the human reader), so that only the ones needed for a given compilation unit are instantiated. Further the link stage, which is difficult to parallize, is a bottleneck.
- flohofwoe 6y agoIt's not just about compile speed, but also about staying sane while working on the project ;)