Hacker News new | ask | show | jobs
by tadeegan 1494 days ago
> 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?

2 comments

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

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.