Boost logo

Boost :

From: Gennaro Prota (gennaro_prota_at_[hidden])
Date: 2002-12-18 17:41:32


--- David Abrahams <dave_at_[hidden]> wrote:

> 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!

I'd much prefer... hey hey, I'm just joking!!! ;-) Seriously, I don't have
Metrowerks but have you tried adding "superflous" parentheses and/or putting 1
as first addendum? Usually parse errors (dis)appears easily that way.

For Borland (unless you are happy with a warning), you can try (variations on)
this idea:

// There seems to be no way to make Borland honor 5p5
// when evaluating the controlling expression of a #if,
// but it supports sizeof expressions therein.
//
#define BOOST_WORKAROUND(symbol, test) \
            ((symbol != 0) && \
        (1 != sizeof(char[((symbol) test) == -1 ? 0 : 1 + ((symbol) test)])))

Please take no notice of the style, I'm a little in a hurry, and the purpose is
just to describe the idea.

Genny.

__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com


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