Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2002-12-18 13:48:00


Gennaro Prota <gennaro_prota_at_[hidden]> writes:

> On Tue, 17 Dec 2002 11:44:12 -0000, "John Maddock"
> <jm_at_[hidden]> wrote:
>
>>Personally I would rather that you stuck to the simplest possible
>>implementation, and for me that outweighs the advantages that using the pp
>>lib might bring. The recent discussion is all very clever, but I'm not
>>convinced that it really adds anything.
>
> As to possible alternatives, my idea is to use two different macros:
> the BOOST_WORKAROUND version, which Dave has already implemented, and
> another one that doesn't let you specify a test, just the version. The
> point is: what test could the user specify that can be negated without
> giving unwanted errors when detection of outdated workarounds is
> enabled? Basically, only <= (For instance: if you specify == 0x600,
> you just risk to get an error when testing with version 0x500). That
> considered, I would say: let him just specify the version with
> something like
>
> #define ERROR(cond) (1 / (cond? 0 : 1))
> #define WORKAROUND_WITH_CHECK(symbol, version) ( \
> ((symbol) != 0) \
> && ERROR(DETECT_OUTDATED && (symbol > version) ) \
> )
>

I'd much prefer:
    BOOST_WORKAROUND(__SUNPRO_CC, BOOST_LATEST_VERSION(0x530))

Which I think is easily achievable, no?

    # define BOOST_WORKAROUND(symbol, test) (symbol != 0) && (1 % ((symbol test) + 1))
    # ifdef BOOST_DETECT_OUTDATED
    # define BOOST_LATEST_VERSION(value) >value?-1:1
    # else
    # define BOOST_LATEST_VERSION(value) != 0
    # endif

    int x = 0;

    # if BOOST_WORKAROUND(COMPILER_VERSION, < 20)
    int y = 0;
    # elif BOOST_WORKAROUND(COMPILER_VERSION, BOOST_LATEST_VERSION(20))
    int z = 0;
    # endif

This seems to work for everything but metrowerks, which says:

    ### mwcc Compiler:
    # File: foo.cpp
    # ----------------
    # 16: ( 21 != 0) && (1 % (( 21 >20?-1:1) + 1))
    # Error: ^
    # expression syntax error

:(

If anyone can come up with a workaround, I'd be psyched!

-- 
                       David Abrahams
   dave_at_[hidden] * http://www.boost-consulting.com
Boost support, enhancements, training, and commercial distribution

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