[config] BOOST_GNUC_FULL_VERSION

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? -- Dave Abrahams Boost Consulting www.boost-consulting.com

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?
Something similar is suggested in the CPP manual, here: http://gcc.gnu.org/onlinedocs/gcc-4.0.0/cpp/Common-Predefined-Macros.html Quick paste: #define GCC_VERSION (__GNUC__ * 10000 \ + __GNUC_MINOR__ * 100 \ + __GNUC_PATCHLEVEL__) ... /* Test for GCC > 3.2.0 */ #if GCC_VERSION > 30200 -- Pedro Lamarão Desenvolvimento Intersix Technologies S.A. SP: (55 11 3803-9300) RJ: (55 21 3852-3240) www.intersix.com.br Your Security is our Business

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

Jonathan Turkanis wrote:
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
# define BOOST_GCC_FULL_VERSION 0
# endif
Jonathan

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?
Actually I thought it had already been done (Gennadiy Rozental was going to add this I thought), so please do go ahead! John.

Actually I thought it had already been done (Gennadiy Rozental was going to add this I thought), so please do go ahead!
Yep. My fault. It was at the moment when I thought we were almost ready to release (month ago) and in a hurry to make all necessary fixes I forgot about this one. Gennadiy
participants (5)
-
David Abrahams
-
Gennadiy Rozental
-
John Maddock
-
Jonathan Turkanis
-
Pedro Lamarão