
On Tue, Jun 9, 2009 at 1:26 PM, Vladimir Prus <vladimir@codesourcery.com>wrote:
Zachary Turner wrote:
I would like to propose conditional support for #pragma once be added to all header files in boost. This would involve, at the beginning of every header file, a preprocessor check to determine whether or not the particular compiler is on a whitelist of known compilers to optimized #pragma once. If so, #pragma once is used. so, something like this:
#if defined(_MSC_VER) /* || defined(OTHER_PRAGMA_ONCE_ENABLED_COMPILER) ... */ #pragma once #endif
If you are proposing to add this to every single file to boost, I am afraid you get to either do it, or provide a script to do this automatically. You might also have to patch the inspect program to automatically catch headers that don't have such preamble. Finally, you have to some form of the check that does not requires that every single header be updated if new compiler is added to white-list.
Because Boost has >90 libraries now, there's zero chance to have such global change to happen unless you do necessary automation. And, it would be surely interesting if Boost itself can benefit from this approach, before we commit to it.
I agree that it would need to be automated. But the script itself should be very trivial, I'd be willing to try it myself. And perhaps the best approach is what I mentioned in a previous post, to force the programmer to explicitly define BOOST_USE_PRAGMA_ONCE before including a boost header file. This would solve the problem of having to modify every header when new compilers were released. And since by default it would be undefined, an out-of-the-box boost installation would work exactly as it does now. I'll work on this a bit later today perhaps, and try to post some benchmarks for for compiling boost itself, and for compiling a commercial product which uses boost.