Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

10
  • 3
    I fail to see the objection to this method. Assuming you generate the includes from a script or Makefile, it is not a maintenance problem. It does in fact speed up compilation without obfuscating compilation issues. You could argue memory consumption on compilation but that is rarely an issue on modern machine. So what is the object to this approach (aside from the assertion that it's wrong)? Commented Mar 4, 2013 at 1:33
  • 9
    @rileyberton (since someone upvoted your comment) let me spell it out: no it doesn't speed compilation up. In fact, it makes sure that any compile takes the maximum amount of time by not isolating translation units. The great thing about them is, that you don't need to recompile all .cpp-s if they didn't change. (That's disregarding stylistic arguments). Proper dependency management and perhaps precompiled headers are much much better. Commented Mar 4, 2013 at 8:55
  • 8
    Sorry, but this can be a very efficient method for speeding up compilation, because you (1) pretty much eliminate linking, and (2) only have to process commonly used headers once. Also, it works in practice, if you bother to try it. Unfortunately, it makes incremental rebuilds impossible, so every build is completely from scratch. But a full rebuild with this method is a lot faster than what you'd get otherwise Commented Mar 4, 2013 at 9:00
  • 4
    @BartekBanachewicz sure, but what you said was that "it doesn't speed compilation up", with no qualifiers. As you said, it makes every compile take the maximum amount of time (no partial rebuilds), but at the same time, it dramatically reduces the maximum compared to what it'd otherwise be. I'm just saying it's a bit more nuanced than "don't do this" Commented Mar 4, 2013 at 9:04
  • 2
    Have fun with static variables and functions. If I want a big compilation unit, I'll create a big .cpp file. Commented Mar 27, 2014 at 9:17