3 ms·
It might as well talk about #pragma once if it is explaining include guards. Fun fact: Oracle (Sun) Studio doesn't support #pragma once. Instead, it actually l
by apaprocki 13y ago
It might as well talk about #pragma once if it is explaining include guards.
Fun fact: Oracle (Sun) Studio doesn't support #pragma once. Instead, it actually looks for proper include guards in the header and if they exist, it optimizes away re-includes of the file if the condition is false.
- dfbrown 13y agogcc does this as well (though it also supports #pragma once). I believe the current convention is to prefer #ifndef include guards as it is more portable and most compilers can detect and avoid re-including files with them.
- ben0x539 13y agoI assumed that was common practice.
- apaprocki 13y agoNope, and to make matters worse -- IBM xlC doesn't optimize at the include sites. So adding include-site guards actually speeds up compilation times in a non-insignificant way. e.g., #ifndef FOO_H #include <foo.h> #endif