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

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

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 +
  # else
  # define BOOST_GCC 0
  # endif


Boost list run by bdawes at, gregod at, cpdaniel at, john at