Boost logo

Boost :

From: Edward Diener (eddielee_at_[hidden])
Date: 2005-07-11 16:48:12


David Abrahams wrote:
> Edward Diener <eddielee_at_[hidden]> writes:
>
>
>>>Maybe that wasn't the best choice of words. I just meant that we'd
>>>lose the functionality provided by BOOST_WORKAROUND if we started
>>>using the macros you suggest instead.
>>
>>We would not so much as lose the functionality as offer a more
>>simplistic and readable way to express it. My suggestion is just about
>>readability. When I see:
>>
>>#if BOOST_WORKAROUND(nnnn,comparison operator)
>>
>>I often can not tell to what it refers without some comment. But if I
>>saw, as an example:
>>
>>#if BOOST_COMPILER_VC71
>>
>>it becomes easier to understand.
>
>
> You obviously didn't read the entire comment in workaround.hpp then.
> #if BOOST_COMPILER_VC71 can't support
> BOOST_DETECT_OUTDATED_WORKAROUNDS.

You mean the BOOST_TESTED_AT syntax ? No, it does not support that.
However one could create a series of macros, let us say for VC71, like this:

// These are always defined and included in a header file at the top of
select_compiler_config.hpp

#define BOOST_COMPILER_VC _MSC_VER
#define BOOST_COMPILER_VC71_VERSION (1310)
#define BOOST_COMPILER_VC71_VERSION_HIGH (1310) // This would be different for a
later service pack of VC71 which had a higher _MSC_VER, and is the only define
that might ever need to be changed for this compiler/version

// These are defined as 0 unless the Microsoft compiler header is selected in
which case the definitions below are in a header file at the top of visualc.hpp

#define BOOST_COMPILER_VC71_OR_HIGHER (BOOST_COMPILER_VC >=
BOOST_COMPILER_VC71_VERSION)
#define BOOST_COMPILER_VC71_OR_LOWER (BOOST_COMPILER_VC <=
BOOST_COMPILER_VC71_VERSION_HIGH)
#define BOOST_COMPILER_VC71 (BOOST_COMPILER_VC71_OR_HIGHER &&
BOOST_COMPILER_VC71_OR_LOWER)

You could now say:

#if BOOST_WORKAROUND(BOOST_COMPILER_VC,BOOST_COMPILER_VC71_VERSION)
// code
#endif

or, in a different situation:

#if
BOOST_WORKAROUND(BOOST_COMPILER_VC,BOOST_TESTED_AT(BOOST_COMPILER_VC71_VERSION_HIGH))
// code
#endif

or, in a different situation:

#if BOOST_COMPILER_VC71 // and any other combinations you like
// code
#endif

etc.

If you are arguing for only using BOOST_WORKAROUND, and never using a construct
like the last one, then you are advocating always using specific version
numbers. In that case you may want to consider at least forms like
BOOST_COMPILER_VC71_VERSION and BOOST_COMPILER_VC71_VERSION_HIGH useful for your
BOOST_WORKAROUND and BOOST_TESTED_AT macros.

Of course you would have the same macros for each compiler/version, as an
example with BORLAND instead of VC, __BORLANDC__ instead of _MSC_VER. and BCB6
instead of VC71. I am sure you get the idea. For BCB6 it would like like this:

// These are always defined and included in a header file at the top of
select_compiler_config.hpp

#define BOOST_COMPILER_BORLAND __BORLANDC__
#define BOOST_COMPILER_BCB6_VERSION (0x560)
#define BOOST_COMPILER_BCB6_VERSION_HIGH (0x564) // this is the only define that
might ever need to be changed for this compiler/version

// These are defined as 0 unless the Borland compiler header is selected in
which case the definitions below are in a header file at the top of borland.hpp

#define BOOST_COMPILER_BCB6_OR_HIGHER (BOOST_COMPILER_BORLAND >=
BOOST_COMPILER_BCB6_VERSION)
#define BOOST_COMPILER_BCB6_OR_LOWER (BOOST_COMPILER_BORLAND <=
BOOST_COMPILER_BCB6_VERSION_HIGH)
#define BOOST_COMPILER_BCB6 (BOOST_COMPILER_BCB6_OR_HIGHER &&
BOOST_COMPILER_BCB6_OR_LOWER)

You could now say:

#if BOOST_WORKAROUND(BOOST_COMPILER_BORLAND,BOOST_COMPILER_BCB6_VERSION)
// code
#endif

or, in a different situation:

#if
BOOST_WORKAROUND(BOOST_COMPILER_BORLAND,BOOST_TESTED_AT(BOOST_COMPILER_BCB6_VERSION_HIGH))
// code
#endif

or, in a different situation:

#if BOOST_COMPILER_BCB6 // and any other combinations you like
// code
#endif

etc.

All of this is syntactic sugar so that the BOOST_WORKAROUND, BOOST_TESTED_AT, or
the raw #if versiontag op nnnn, is more readable.


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