Boost logo

Boost :

From: Angus Leeming (angus.leeming_at_[hidden])
Date: 2005-10-14 15:02:34


David Abrahams wrote:

> Angus Leeming <angus.leeming_at_[hidden]> writes:
>
>> Compiling the attached code with g++ 3.4.4 as
>> g++ -Wundef -Iboost/cvs -o trial trial.cpp
>> produces a heap of warnings
>> warning: "__BORLANDC__" is not defined
>> warning: "_MSC_FULL_VER" is not defined
>> warning: "__MWERKS__" is not defined
>>
>> The warnings are produced by code like:
>> #if BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3003))
>>
>> and are, of course, silenced by:
>> #if defined(__MWERKS__) && \
>> BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3003))
>>
>> Grepping around the boost sources, I see that my 'fix' has been applied
>> about 70 times already in the 1260 uses of BOOST_WORKAROUND. Assuming
>> that the lack of consistency reflects only the size of the task, I've
>> made a patch applying the fix to Boost.Random. Chipping away at the
>> block...
>
> I object to adding all these specific silencing tests. IIRC we were
> going to handle this by creating boost macros for each compiler,
> similar to BOOST_MSVC, that were always #defined (possibly to 0), and
> using those in the BOOST_WORKAROUND tests. Otherwise, we will end up
> uglifying a lot of code, where BOOST_WORKAROUND is supposed to make
> the code much simpler and more readable.

Right. Agree 100%.

The problem is that, at the moment, no such macro is always defined. How
about macros like this in workaround.hpp:

======================================================
#if defined(__BORLANDC__)
# define BOOST_WORKAROUND_BORLANDC(X) BOOST_WORKAROUND(__BORLANDC__, X)
#else
# define BOOST_WORKAROUND_BORLANDC(X) 0
#endif

#if defined(__GNUC__)
# define BOOST_WORKAROUND_GNUC(X) BOOST_WORKAROUND(__GNUC__, X)
#else
# define BOOST_WORKAROUND_GNUC(X) 0
#endif
======================================================

to be used so:
======================================================
#include <boost/detail/workaround.hpp>

#if BOOST_WORKAROUND_BORLANDC(BOOST_TESTED_AT(0x3003))
# error __BORLANDC__ < 0x3003
#elif BOOST_WORKAROUND_GNUC(BOOST_TESTED_AT(4))
# error __GNUC__ < 4
#elif BOOST_WORKAROUND_GNUC(BOOST_TESTED_AT(3))
# error __GNUC__ < 3
#endif
======================================================

That would be simple and readable, no?

Sorting through the sources, it appears that there are BOOST_WORKAROUNDS
used for the following macros (extraction script also below). Would you
like me to proceed on a bitwise basis, defining macros as above and then
applying it to the code base, or can you describe a better way (for me) to
proceed?

Regards,
Angus

BOOST_DINKUMWARE_STDLIB
BOOST_DYNAMIC_BITSET_GNUC_VERSION
BOOST_INTEL
BOOST_INTEL_CXX_VERSION
BOOST_INTEL_WIN
BOOST_IOSTREAMS_GCC
BOOST_MPL_CFG_GCC
BOOST_MSVC
BOOST_RWSTD_VER
__BORLANDC__
__COMO__
__COMO_VERSION__
_COMPILER_VERSION
_CRAYC
__DECCXX_VER
__DMC__
__EDG__
__EDG_VERSION__
__GLIBCPP__
__GNUC__
__GNUC_MINOR__
__GNUC_PATCHLEVEL__
__HP_aCC
__IBMCPP__
__ICL
__INTEL_COMPILER
_MSC_FULL_VER
_MSC_VER
MSVC
__MWERKS__
_RWSTD_VER
__SGI_STL_PORT
_STLPORT_VERSION
__SUNPRO_CC
symbol

$ grep -r BOOST_WORKAROUND boost | \
sed '
# Strip filename
s/[^:]*://
# Ignore comments
s/\/\/.*//
# Strip lines that no longer contain BOOST_WORKAROUND
/BOOST_WORKAROUND/!d
# Extract the compiler macro
s/.*BOOST_WORKAROUND *( *\([^ ,]\{1,\}\).*/\1/
' workaround.txt | sort -u


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