I
Ian Collins
I think, if one needs to support a compiler that doesn't support
`#pragma once`, then one is in about the same kind of boat as one who is
targeting a 16-bit char system: one is not writing portable code.
So, big difference between formal and practice.
But here's the crucial thing: if up-front generation of include guards
is feasible, and it is, then for those special compilers (like 16-bit
Digital Signal Processor compiler) it's no big deal to preprocess the
source replacing `#pragma once` with traditional include guards.
Well my day to day compiler (Sun CC) does not use `#pragma once` and I
have never seen it used in Unix, Linux or embedded system headers.
In a way, `#pragma once` is an anachronism. The preprocessor can keep
track of open headers with include guards and not reopen the file. Both
Sun CC and gcc appear to be doing this.
It is probably a worthwhile optimisation, I bet most of the headers
encountered in a typical build are system or third party library headers
that do no use `#pragma once`.