Boost logo

Boost :

Subject: Re: [boost] numeric_cast
From: Mateusz Loskot (mateusz_at_[hidden])
Date: 2011-06-27 19:19:47


On 27/06/11 21:42, Edward Diener wrote:
> On 6/27/2011 12:59 PM, Stephan T. Lavavej wrote:
>> [Mateusz Loskot]
>>> Is location of #pragma relevant? Meaning, having #pragma nested in
>>> #ifndef include guard vs. placing it in outer scope, makes difference or
>>> not?
>>
>> VC doesn't care where the #pragma once is, but as I recall, other
>> compilers care where the #ifndef is - they prefer it to be on the
>> outside of everything else, except comments.
>
> I doubt if any compiler cares where the #ifndef ( or #if !defined ) is.
> It is just C++ after all and the preprocessor should handle it according
> to the C++ standard. It has just become conventional to write:
>
> #ifndef SOME_MACRO
> #define SOME_MACRO
>
> // header code
>
> #endif

My question was if related to #pragma once specifically
and previous comments on why to use it together with include guards.
So, I asked if Visual C++ handles these two in the same or different manner:

1)

#ifndef SOME_MACRO
#define SOME_MACRO

#pragma once

// header code

#endif

2)

#pragma once

#ifndef SOME_MACRO
#define SOME_MACRO

// header code

#endif

Best regards,

-- 
Mateusz Loskot, http://mateusz.loskot.net
Charter Member of OSGeo, http://osgeo.org
Member of ACCU, http://accu.org

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