
16 Nov
2012
16 Nov
'12
8:12 p.m.
10.04.2009, 23:26, "Marcus Lindblom" <macke@yar.nu>:
In addition #pragma once may be faster than #ifndef/#endif because the compiler is not even going to open the file a second time to parse the #ifndef/#endif.
I've seen benchmarks that say some compilers (gcc, msvc) are smart enough to recognize #ifndef/#endif and do the #pragma once equivalent. (i.e. there's no discernable performance difference.)
Can't find the link now though.. :(
It's in the docs of GCC, for example (even the ancient version 2.95.0 was optimized not to read same file twice if guards surround the whole file): http://gcc.gnu.org/onlinedocs/gcc-2.95.3/cpp_1.html#SEC8 Thanks, Maxim