Boost logo

Boost :

Subject: Re: [boost] Proposal for #pragma once support
From: Emil Dotchevski (emildotchevski_at_[hidden])
Date: 2009-06-09 23:14:34


On Tue, Jun 9, 2009 at 7:58 PM, Scott McMurray<me22.ca+boost_at_[hidden]> wrote:
> 2009/6/9 Christopher Jefferson <chris_at_[hidden]>:
>>
>> One thing to watch out for, in case you don't notice in advance: Some
>> headers should NOT have #pragma once. Not very many, but such files exist.
>> You'll probably want to try to find some way of guessing if a file already
>> has a standard include guard (shouldn't be too hard to detect), and only
>> #pragma once such files.
>>
>
> Which is exactly what GCC does to not need #pragma once =)
>
> (And that check can be made fast by allowing the pathological cases to
> fall back to the normal include guard behaviour, as that's still safe,
> whereas #pragma once always has to go the slow route of canonizing all
> the paths -- which isn't even always possible -- to be safe.)

You're making the same point I was thinking about earlier, which is
that in theory #pragma once shouldn't be faster than include guards.
So how about this:

#include <boost/detail/workaround.hpp>
#if defined(BOOST_MSVC) && BOOST_WORKAROUND(BOOST_MSVC, < 1500)
#pragma once
#endif

Emil Dotchevski
Reverge Studios, Inc.
http://www.revergestudios.com/reblog/index.php?n=ReCode


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk