Boost logo

Boost :

From: Jonathan Turkanis (technews_at_[hidden])
Date: 2005-07-05 16:31:46


David Abrahams wrote:
> Someone at one point suggested we add something like this:
>
> # ifdef __GNUC_PATCHLEVEL__
> # define BOOST_GNUC_FULL_VERSION ((__GNUC__ * 1000UL +
> __GNUC_MINOR__) * 1000UL + __GNUC_PATCHLEVEL__) # else
> # define BOOST_GNUC_FULL_VERSION 0
> # endif
>
> Without it, testing for GCC versions is painful. I'd like it; can we
> do it?

I'd like it too. I have some comments, though:

1. Is it really necessary to multiply each component by 1000? The GCC docs
recommend using 100:
http://gcc.gnu.org/onlinedocs/gcc-4.0.0/cpp/Common-Predefined-Macros.html

2. The patch-level is used infrequently in the Boost codebase -- I can only find
three files which use it -- whereas __GNUC__ and __GNUC_MINOR__ are used all
over the place. Since including the patch-level makes it a bit harder to test
against the macro -- especially if you use 1000 instead of 100 -- I think we
should provide a macro incroporating just the major and minor version.

3. When this issue was raised some time ago, it was decided that it's better to
base compiler-identification macros on the compiler name than on the vendor
name: http://lists.boost.org/boost/2004/03/3081.php.

As a result, I'd recommend something like:

  # ifdef __GNUC_PATCHLEVEL__
  # define BOOST_GCC (__GNUC__ * 100UL + __GNUC_MINOR__)
  # define BOOST_GCC_FULL_VERSION ((_GNUC_ * 100UL + __GNUC_MINOR__) * 100UL +
__GNUC_PATCHLEVEL__)
  # else
  # define BOOST_GCC 0
  # endif

Jonathan


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