Boost logo

Boost :

From: Angus Leeming (angus.leeming_at_[hidden])
Date: 2005-10-17 08:38:08


David Abrahams wrote:

> Angus Leeming <angus.leeming_at_[hidden]> writes:
>> Is there any need for 'BOOST_WORKAROUND(BOOST_MSVC, < foo)'
>> anymore. Why not just 'BOOST_MSVC < foo'

> Yes. Read the documentation in boost/detail/workaround.hpp.
> It does a whole lot more than that.

Dave, Rene, all interested in cleaning up these macros,

I've written a little script to convert the current preprocessor
commands to the ones that I think you'd like to see. It's a shell
script but would be trivial to convert to python if you want the
script itself and want it to run from a Windows box.

For now, I've concentrated solely on BOOST_MSVC. Moreover, the script
checks only the files in the boost subdirectory. It doesn't go into
libs or test. I anticipate that it'll be straightforward to extend to
cover other macros and subdirectories.

The script, attached as boost_msvc.sh, produces boost_msvc.txt, also
attached, when run from the top-level directory of the boost tree.
At the moment, the script simply prints out the 'before' and 'after'
of any preprocessor commands it's changed, separating each one with a
blank line to improve legibility.

-#if !defined(BOOST_MSVC)
+#if (BOOST_MSVC == 0)

-#ifdef BOOST_MSVC
+#if (BOOST_MSVC > 0)

-#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300)
+#if (BOOST_MSVC < 1300)

I believe that the script performs the conversion that you'd like to
see. Please confirm that I'm on the right track.

Reading through the output, however, it appears to me that the script
could go further. For example, to test for BOOST_MSVC and to then
use _MSC_VER seems slightly ridiculous:

-defined(BOOST_MSVC) && (_MSC_VER <= 1300)
+(BOOST_MSVC > 0) && (_MSC_VER <= 1300)

Wouldn't you rather see:
+BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
?

Similarly, there are a lot of naked (BOOST_MSVC <= 1300). Would you
prefer to see these replaced by the equivalent
BOOST_WORKAROUND(BOOST_MSVC, <= 1300) ?

One final question: it appears that many (most?) tests ignore the
existence of BOOST_TESTED_AT(X). Is there a real reason for doing so,
or is it simply that '<= 1300' is less typing than
BOOST_TESTED_AT(1300)? Would you like me to extend the script to use
BOOST_TESTED_AT(X) consistently?

Regards,
Angus





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