TGViewer
C++ - Reddit C++ - Reddit @r_cpp · 229 subscribers
Post #24809 23
Am I the only one who feels like header files in C/C++ are duplication?

We declare things in headers, define them in source, keep them in sync manually, sprinkle include guards everywhere... all to prevent problems caused by the very system we are forced to use. It's like writing code to defend against the language's file model rather than solving actual problems.

And include guards especially - why is "dont include the same header twice" something every project has to re-implement manually? Why isn't that just the compiler's default behavior? Who is intentionally including the same header multiple times and thinking "yes, this is good design"?

It feels like a historical artifact that never got replaced. Other languages let the compiler understand structure directly, but here we maintain parallel representations of the same interface.

Why can't modern C++ just:

treat headers as implicitly guarded, and maybe
auto-generate interface declarations from source files?


https://redd.it/1rgyeqp
@r_cpp
Reddit From the cpp community on Reddit Explore this post and more from the cpp community
More from @r_cpp
  1. Oct 7, 2026Jean Frantz René: C++ Memory safety for safety-critical and non-safety critical applicatio…
  2. Oct 7, 2026Full Meeting C++ 2026 program released https://meetingcpp.com/mcpp/schedule/#2026 https://…
  3. Oct 7, 2026Qt moc now can handle basic C++ modules (Qt 6.12) https://codereview.qt-project.org/c/qt/q…
  4. Oct 7, 2026New to c++ Hello everybody,im new to cpp,and want to learn it,i have some knowledge with C…
  5. Oct 7, 2026Optimizing the Compressed Log Pipeline: https://github.com/Tencent/BqLog/blob/main/docs/Ar…
  6. Oct 7, 2026BqLog 2.6.0: a C++ logging library running on 30M+ devices daily, benchmarked against quil…
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →