Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2002-12-11 15:36:39


"Paul Mensonides" <pmenso57_at_[hidden]> writes:

> ----- Original Message -----
> From: "Gennaro Prota" <gennaro_prota_at_[hidden]>
>
>> Yes. It would be nice if we could come up with an implementation of
>> BOOST_WORKAROUND or another macro, let's say
>> BOOST_UNVERSIONED_WORKAROUND, that generates a warning or (more
>> realistically) an error when you invoke it with e.g.
>>
>> BOOST_UNVERSIONED_WORKAROUND(__BORLANDC__, 0x569)
>>
>> and __BORLANDC__ expands to a value greater than 0x569. That would be
>> a reminder for the maintainer to either bump 0x569 to a higher value
>> (i.e. to update the "last checked comment") or change the invocation
>> to BOOST_WORKAROUND(__BORLANDC__, <= 0x569)). But off the top of my
>> head I can't think any way to do that.
>
> It's possible with a little scaffolding.
>
>> The point is of course that if the compiler is fixed an unversioned
>> check will still use the workaround, silently. Well, there are special
>> cases where this doesn't hold; e.g. one of the tests we have in
>> dynamic_bitset: had I written
>
> The preprocessor library uses unversioned checks. The maintenance cost
> associated with bumping up all the versions referred to would be high. I
> think it makes a big difference with whether or not a workaround requires
> using behavior that is non-compliant. If it doesn't, an unversioned check
> is better, IMHO. At the same time, some type of "use strict mode" macro
> should unilaterally force the non-workaround version. This is a good way to
> find if new compiler versions or previously untested compilers can handle
> the strict code.
>
> [snip]
>
>> Such a macro would help the programmer to not "forget" to check
>> whether the workaround is still needed. As an alternative we could
>> decide to ban unversioned checks at all. I don't know, it depends on
>> whether we consider more important avoiding the mainteinance burden or
>> exploting the compiler (or library) capabilities.
>
> It is possible to make it generate a warning or an error if a compiler
> version is higher than the specification.

How?

What we want is something that can be used like:

   #define BOOST_WORKAROUND(symbol,test) (((symbol) != 0) && ((symbol) test))

 #if BOOST_WORKAROUND(__SUNPRO_CC, <= 0x530)
     // workaround code
 #endif

How can we say

 #if BOOST_WORKAROUND(__SUNPRO_CC, /*something involving 0x530 */)

and have it enter the #if and warn when __SUNPRO_CC > 0x530 ?

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