3 ms·
The more modern gcc handling is with "#pragma once": I've considered switching to this, but in the interest of maximum hypothetical portability, I've decided t
by nitrogen 15y ago
The more modern gcc handling is with "#pragma once":
I've considered switching to this, but in the interest of maximum hypothetical portability, I've decided to stick with the #ifndef include guard. I've just checked the C1X standard draft I have, and #pragma once is still not in the standard (6.10.6.1 in the version I have).
As for your other points, I agree with the notion that a header file should include its dependencies, but no more. I suppose my thinking on this is influenced by the dependency tracking of Linux package managers such as apt.
- apaprocki 15y agoWe use both internally, actually. GNU gcc/g++ and IBM xlc/xlC all support doing this: #if defined(... all the compilers above ...) # define PRAGMA_ONCE _Pragma("once") #else # define PRAGMA_ONCE #endif Specifically, MSVC and HP cc/aCC do not support it. Oracle cc/CC does the #ifndef/#define detection and internally does something similar to what the pragma enables in other compilers.