TGViewer
C++ - Reddit C++ - Reddit @r_cpp · 229 subscribers
Post #24337 19
#pragma once -> two files are identical if their content is identical

It is that simple.
Two files are considered identical, if their content is identical.
Forget about paths, inodes, whatever other hacks.
Define it like this, it can probably fit in one paragraph of standardize, and be done with it.

After that, compilers are free to do any heuristics and optimizations that help to identify two files as identical, that is perfectly fine.
When the compiler cannot say for sure that two files are the same, it will have to read it, but guess what? If the files are actually different files, it has to read it anyway, to include it in the translation unit.

(btw I am watching the 2 hour video of rants about c++ right now, this issue just strikes me, as i have had enough of conversations about it myself.)

https://redd.it/1p5lg3t
@r_cpp
Reddit From the cpp community on Reddit Explore this post and more from the cpp community
More from @r_cpp
  1. Oct 12, 2026ACCU Overload Journal 195 - October 2026 https://accu.org/journals/overload/overload195 ht…
  2. Oct 12, 2026C++ Contracts C++ contracts are a good thing, why are people saying it's a bad thing? Anyb…
  3. Oct 11, 2026wxWidgets 3.2.12 and 3.3.4 Released https://wxwidgets.org/news/2026/10/wxwidgets-3.2.12-an…
  4. Oct 11, 2026VKRT NES Remaster — an open-source C++20 NES emulator with an observation-driven remasteri…
  5. Oct 11, 2026Right way to test async code https://redd.it/1x2wqgz @r_cpp
  6. Oct 10, 2026Yantra: an LALR(1) parser generator for C++23 Yantra: an LALR(1) parser generator for C++2…
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 →