Boost logo

Boost :

From: deansturtevant_at_[hidden]
Date: 2000-12-17 12:10:14


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

The cost of this approach, as I see it:

1. The boost library build process would be more complex. (Note: we
could have two libraries or just one. I would recommend two so that
unintentional mixed use of debug and ndebug code can be caught at
link time).

2. When defining symbols inside the boost namespace, one would need
to use BOOST_NAMESPACE. (You can't use boost because in debug mode
it's not a namespace name, just an alias. Aliases can't be used in
place of namespace names when defining scopes. :-( )

e.g., a boost header file would contain code looking like

namespace BOOST_NAMESPACE {
void neat_stuff();
}

and the client would write code using 'boost'

     boost::neat_stuff();


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