Boost logo

Boost :

From: David Abrahams (abrahams_at_[hidden])
Date: 2000-12-17 14:37:55


----- Original Message -----
From: <deansturtevant_at_[hidden]>
> Here is a way to avoid ODR problems with assert() (Not that I'm
> recommending we do this!). The idea is that if NDEBUG isn't defined,
> then "boost" is really "boost_debug". The boost library would then
> have to be compiled twice, once with NDEBUG defined, once without. In
> order to avoid #defining boost (which would cause problems in code
> that defines 'boost' as a symbol name), we'd need to use a macro such
> as BOOST_NAMESPACE when defining symbols inside boost. It would look
> something like this:
>
> #ifndef NDEBUG
> #define BOOST_NAMESPACE boost_debug
> namespace boost_debug {}
> namespace boost = boost_debug;
> #else
> #define BOOST_NAMESPACE boost
> #endif

How does this get us an ASSERT which avoids the problem? Try writing one and
you'll see what I mean. The issue is that there must be no cost to
evaluating the condition in shipping builds, so
BOOST_ASSERT(<complicated-expression>) can be had for free. Also, of course,
the code generated in a function using BOOST_ASSERT must be the same
regardless of the setting of NDEBUG to keep the ODR happy. These
requirements seem to be fundamentally in conflict.

-Dave


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