News for hackers. Stuff that matters.
Re:Extreme include discipline for C++ code by tadeegan on Friday May 13, 2022 @09:26AM (#31367293)
> It's a known problem so we mitigate with #ifdef guards, #pragma one etc. but in my experience those band-aids don't solve the problem.

Errr, why?

Re:Extreme include discipline for C++ code by deutschepost on Friday May 13, 2022 @09:49AM (#31367563)
The "problem" at this part in the text is that the headers still have to get parsed multiple times by the preprocessor. With his approach this would not be necessary.

That said, I don't think that is that big of a problem compared to final compile time reduction.

EDIT: Disregard that, the preprocessor remembers the states of include guards. So there is literally no point.[1]

[1] https://gcc.gnu.org/onlinedocs/cpp/Once-Only-Headers.html

Re:Extreme include discipline for C++ code by ur-whale on Friday May 13, 2022 @09:28AM (#31367316)
Yeah, came here to say the same thing.

Plus:

> I don't think I've ever seen any C++ code bases that follows this rule.

It's not particularly useful to do this given that the moment you include anything from /usr/include and STL that rule will get broken from under you a 100 times.