Boost logo

Boost :

From: Edward Diener (eddielee_at_[hidden])
Date: 2005-07-10 21:12:20


David Abrahams wrote:
> Edward Diener <eddielee_at_[hidden]> writes:
>
>
>>David Abrahams wrote:
>>
>>>Edward Diener <eddielee_at_[hidden]> writes:
>>>
>>>
>>>
>>>>It would be much easier, and less confusing, when looking at compiler
>>>>workarounds in Boost code if their were defines for various
>>>>compilers/versions in a configuratiion header file such as:
>>>>
>>>>#define BOOST_COMPILER_SOME_COMPILER_LOWER (PREPROCESSOR_TAG >= nnnn)
>>>>#define BOOST_COMPILER_SOME_COMPILER_UPPER (PREPROCESSOR_TAG <= nnnn)
>>>>#define BOOST_COMPILER_SOME_COMPILER (BOOST_COMPILER_SOME_COMPILER_LOWER
>>>>&& BOOST_COMPILER_SOME_COMPILER_UPPER)
>>>
>>>
>>>Not sure why you'd want to do that. Then you only get a binary value
>>>for BOOST_COMPILER_SOME_COMPILER.
>>
>>You would get a boolean of true or false.
>
>
> That wouldn't be very useful in Boost. If you look through Boost code
> you'll find a lot of places where a <, <=,>, or >= comparison is
> needed against a compiler version.

The way I have set it up, for example, is to use

#define BOOST_COMPILER_VC6 (...)
#define BOOST_COMPILER_VC6_OR_LOWER (...)
#define BOOST_COMPILER_VC6_OR_HIGHER (...)

( along with th same for VC7, VC71, and VC8 )

You could write:

#if BOOST_COMPILER_VC6
// code
#endif

or

#if BOOST_COMPILER_VC6_OR_HIGHER (...)
// code
#endif

or even

#if BOOST_COMPILER_VC6 || BOOST_COMPILER_VC7
// code
#endif

You can imagine the ease of any combinations you like.

Of course if one would rather see:

#if (BOOST_MSVC >= 1310)
// code
#endif

or

#if BOOST_WORKAROUND(BOOST_MSVC,>= 1310)+
// code
#endif

because that is better, then why should I suggest otherwise ?

>
>
>>>I'd rather have a composite version number.
>>
>>I would rather know whether some compiler is being referred to or not.
>
>
> Then learn what the version numbers mean?

Specifying a compiler version via a macro makes the code much clearer.
This does not keep anyone from using BOOST_MSVC if they like or even
combining it with the compiler identiification macros shown above.

>
>
>>>>#if defined(BOOST_COMPILER_VC71) etc.
>>>>
>>>>rather than the less understandable
>>>>
>>>>#if defined(MSC_VER == nnnn) etc.
>>>
>>>
>>>Actually we have BOOST_MSVC. The only reason we'd test _MSC_VER is
>>>for those cases where we want to catch *all* compilers that emulate
>>>VC++ (e.g. for #pragma once).

Ok, Makes sense.

>>
>>Does BOOST_MSVC referring to all versions of MSVC ?
>
>
> Yes.
>
>
>>I wanted something easy which refers to particular major version of
>>particular compiler toward which Boost is targeted.
>
>
> I guess you'd have to make it up yourself, because if we used that in
> Boost it would become a big(ger) mess.

I definitely don't want to make a mess.

>
>
>>Is there a list of general compiler/versions which Boost supports.
>
>
> No
>
>
>>>>I realize I am just a reader of Boost code and not a Boost
>>>>developer but I think this suggestion would make for a little more
>>>>readable code in its own small way.
>>>
>>>
>>>I agree! I suggest you prepare a patch for the config library that
>>>we can use in Boost after 1.33.0
>>>
>>
>>If I can get a comprehensive list of compiler/versions and their
>>corresponding preprocessor symbols I will be glad to do it. I can
>>find out the appropriate information for Microsoft and Borland on
>>Windows easily enough myself.
>
>
> Well, I think I spoke too soon. What you appear to be asking for
> would add little of value to Boost and would undermine the
> capabilities we get from BOOST_WORKAROUND.

I would never want to "undermine" Boost code in any way.


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