[Development] Using '#pragma once' instead of include guards?
Kevin Kofler
kevin.kofler at chello.at
Tue Oct 11 21:20:11 CEST 2022
Paul Colby wrote:
> Also worth considering
> https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Rs-guards
>
> SF.8:
>
>> Note Some implementations offer vendor extensions like #pragma once
>> as alternative to include guards. It is not standard and it is not
>> portable. It injects the hosting machine’s filesystem semantics into your
>> program, in addition to locking you down to a vendor. Our recommendation
>> is to write in ISO C++: See rule P.2.
"locking you down to a vendor" is a funny argument when the Wikipedia
article:
https://en.wikipedia.org/wiki/Pragma_once
cannot name a single compiler that does not support #pragma once, and 20
that do.
Kevin Kofler
More information about the Development
mailing list