
2009/6/11 Sid Sacek <ssacek@securewatch24.com>
Your forgetting about the natural impulse to not want to clutter the code with unnecessary workarounds. Make no mistake, that's all it is, since #pragma once is the wrong feature to add to a compiler if you want to speed up header inclusion.
It might be acceptable in proprietary code that never moves outside of Windows, but since Boost will still have to have normal include guards, #pragma once is just noise, semantically. <snip> I think you can figure out what that means in compiler terms. But since that is not possible at this point in time, a compromise should be made; one that respects both Microsoft compiler users, and the non-Microsoft compiler users. I don't believe that Microsoft has the only compiler that improves its compile-times using #pragma once. So other compilers can also benefit from the #pragma usage as well. My personal experience with large projects is that #pragma once cuts the build time by 26%. Every little bit counts when you're working on very large applications.
A compiler that has a choice between #pragma once or #ifdef XXXXX should see that excluding parsing of the header could be done exactly the same on both, with the difference that the pragma is not generally supported and nonstandard. Any portable code will have to include the latter, making the first one completely pointless. Any speed benefit it gets you is the compiler builder not doing his/her job. Kind regards, Peter Bindels