4 ms·
#include repetition is not really that much of a problem these days. Put all your #includes in one include.h file, and include only that include.h in the rest o
by tbirdz 10y ago
#include repetition is not really that much of a problem these days. Put all your #includes in one include.h file, and include only that include.h in the rest of your code. Then make a precompiled header for include.h (gcc, clang, and even msvc can do this), which will vastly speed up compile times, and compensate for the overhead of including unnecessary headers in your code that doesn't need to include everything.
- jmount 10y agoI think lisper is (rightly) criticizing the repetition of the same code being multiple places due to the includes (not the also irritating need to write the includes multiple places). The problem does go from bad to worse in C and C++ when you work through what happens when static decelerations and method bodies make it into ".h" files. A lot of rules are in place to have these multiple code units appear as a coherent single unit.
- lisper 10y agoExactly right.
- MaulingMonkey 10y ago> Put all your #includes in one include.h file RIP incremental build times. > Then make a precompiled header for include.h (gcc, clang, and even msvc can do this), which will vastly speed up compile times, and compensate for the overhead of including unnecessary headers in your code that doesn't need to include everything. Speaking from experience, god no it doesn't. Those are the codebases where fixing a single typo may take an hour to fully rebuild a single build configuration. As the poor bastard charged with porting things and managing said build configurations, this means I either break the build from time to time, or have to wait overnight to have a full set of builds to test before checking anything in.
- signa11 10y ago> ...vastly speed up compile times, ... Just use ccache if build times are getting atrocious, then focus on getting link times down :)
- MaulingMonkey 10y agoccache won't help much if every TU changes with every typo fix - nothing but cache misses. But yes, use ccache or similar to accomplish proper incremental builds. As for link times: switch from bfd to gold. And maybe play with --incremental. I didn't - just switching to gold shaved minutes off my link times for free, and suddenly link times were no longer my build bottleneck :)