> Date: Sat, 15 Oct 2022 19:21:35 +0000 > From: Taylor R Campbell <riastr...@netbsd.org> > > #pragma once > [...] > How reliable/consistent is toolchain support for it? Is it worth > adopting or is the benefit negligible over continuing to use > traditional #include guards? Likely problems with adopting it?
I wasn't able to find a clear statement of the semantics anywhere: Is it keyed by (dev,ino), by pathname, by some kind of normalized pathname, by file content? gcc's own documentation is very sparse and just describes it as nonportable. I spent a few minutes skimming the code in gcc and it wasn't obvious to me except that it might be indexed by MD5 hash of file content which would be unnerving (unless that's just for precompiled header files or something, didn't spend enough time to be sure). The value seems negligible: clang detects mismatched include guards in a single .h file, which leaves only the problem of overlapping include guards, but it wouldn't be hard with grep to detect that or even teach lint to enforce include guard naming rules. So on balance, #pragma once doesn't seem worthwhile to me today, and I think we should stick to traditional include guards for now.