Subject: Re: [boost] [#pragma once]
From: Sid Sacek (ssacek_at_[hidden])
Date: 2009-04-10 18:34:23
>> #if defined( _MSC_VER ) && ( _MSC_VER >= 1020 )
>> # pragma once
> IMO, there is absolutely no reason to /rely/ on non-standard
> features even if /all/ compilers supported it in this case.
> Steven Watanabe
Just to make a small point; this is from the C++ standard...
16.6 Pragma directive [cpp.pragma]
1 A preprocessing directive of the form
# pragma pp-tokensopt new-line
causes the implementation to behave in an implementation-defined
behavior might cause translation to fail or cause the translator or
program to behave in a non-conforming manner. Any pragma that is
by the implementation is ignored.
If unrecognized pragmas are ignored, then I don't see why boost
developers should jump
through a hoop to satisfy the "el-cheapo" compilers. In other words, if
a compiler gives
a warning about the #pragma-once, then let the programmer turn off the
for the build, which is usually done in a single location within a
On the other hand, every boost.hpp file has to surround the "#pragma
once" with the
silly looking guards.
I tried this experiment just to see what happens. I added the
non-existing #pragma to
my code and got the following warning:
foo.cpp(20) : warning C4068: unknown pragma
My opinion is that the boost headers can happily contain the following
I have not yet heard about a compiler that doesn't support this #pragma.
I would be
surprised if a single developer calls up to complain about this. The
warn against this #pragma can turn off the warnings with a single
like I mentioned before.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk