Boost logo

Boost :

Subject: Re: [boost] Guidence on #pragma once
From: Peter Koch Larsen (peter.koch.larsen_at_[hidden])
Date: 2018-11-24 10:25:12


In my code, I use #pragma once on new stuff, mostly because of lazyness.
That said, there can be esoteric environments where this does not work
so for boost I agree that the oldfashioned include guard is better.
But why not use a guid in that case? This is IMO a better solution,
reducing the risk of having identical names.
With include-guards I do not use pragma once. Why have both? I do not
believe there will be any performance difference with newer compilers.

Peter

On Sat, Nov 24, 2018 at 12:36 AM Robert Ramey via Boost
<boost_at_[hidden]> wrote:
>
> In the safe numerics library my *.hpp files start with the following
> boiler plate:
>
> #ifndef BOOST_NUMERIC_AUTOMATIC_HPP
> #define BOOST_NUMERIC_AUTOMATIC_HPP
>
> // MS compatible compilers support #pragma once
> #if defined(_MSC_VER) && (_MSC_VER >= 1020)
> # pragma once
> #endif
>
> ...
>
> I would like to replace all this in every file with just
>
> #pragma once
>
> according to https://en.wikipedia.org/wiki/Pragma_once#cite_note-9
>
> this should be possible while supporting almost all which claim to be
> C++ 14 conformant. The exception noted is C++ for Cray.
>
> I realize that strictly speaking I shouldn't do this. But it would
> instantaneously remove some cruft from my code as long as the occasional
> error from repeating the same include guard text in multiple files. It
> might have some performance benefits and some other repercussions
> related to pre-compiled headers. Who knows what else. It would be
> interesting to know what others might have to say about this.
>
> Robert Ramey
>
>
> _______________________________________________
> Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost


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