Boost logo

Boost :

From: Angus Leeming (angus.leeming_at_[hidden])
Date: 2005-10-16 18:37:54


David Abrahams wrote:

> Angus Leeming <angus.leeming_at_[hidden]> writes:
>
>> David Abrahams wrote:
>>
>>> 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.
>
> That should be done in boost/config/suffix.hpp

Ie, you'd like to see this in boost/config/suffix.hpp:

#if !defined(BOOST_MSVC)
# define BOOST_MSVC 0
#endif

?

> It isn't just the uses of BOOST_WORKAROUND that will benefit. I'm
> sure there are plenty of legacy tests that should be converted.

Certainly it means lots of change

$ find boost -name '*' | \
  while read file
  do
    grep BOOST_MSVC "$file" >> boost_msvc.txt
  done
$ wc -l boost_msvc.txt
810 boost_msvc.txt

I don't think that such a mammoth change could be done by hand without
significant risk of regressions. That suggests, therefore, that it should
be automated. In itself, that isn't too difficult to contemplate, but some
questions need answering:

I guess that
'#if !defined(BOOST_MSVC)' becomes '#if (BOOST_MSVC > 0)'. Or would you
prefer '#if BOOST_MSVC' ?

Is there any need for 'BOOST_WORKAROUND(BOOST_MSVC, < foo)' anymore. Why
not just 'BOOST_MSVC < foo'

Of course, '#ifdef BOOST_MSVC && BOOST_WORKAROUND(BOOST_MSVC, < 1300)' is
simplified, but to automate the simplification is bloody hard because
preprocessor directives can span multiple lines...

Hmmm. I guess that sed is powerful enough to do the job though.
(There are no TABS in boost's sources, right?)

So, Dave. If you can answer my questions above, I'll give this a shot if
you think that the approach merits further work.

Regards,
Angus

$ find boost -name '*' | \
while read file
do
   test -d $file && continue
   echo "$file" | grep CVS >/dev/null && continue
   sed -n '
# Ignore #includes
/^ *# *include/b

# If the pattern space contains a preprocessor instruction
/^ *#/{
# If the line ends with \ then the instruction continues
# on the next line. Pull that in too.
# Take account of C++-style comments
:loop
/\\ *\(\/\/[^\n]*\)\{0,1\}$/{
$!{
N
bloop
}
}

# The pattern space now contains a complete
# preprocessor instruction.

# For now, just print it out if it contains BOOST_MSVC
/BOOST_MSVC/p

}' $file >> boost_msvc2.txt
done


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