Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2001-11-12 11:12:44

From: "Chris Little" <cslittle_at_[hidden]>
> Since assert is only used if BOOST_ASSERT isn't defined, shouldn't the
> #include be moved inside the #ifndef BOOST_ASSERT?

This is to support the -DBOOST_ASSERT=assert mode, where BOOST_ASSERT maps
directly to 'assert'. It can be changed but <assert.h> is fairly lightweight
so it doesn't matter much.

> Why do we need BOOST_DEBUG instead of just using NDEBUG? Are you assuming
> that people might want use BOOST_ASSERTS in release builds?

Yes. Some people prefer to leave asserts always on, although I now see that
when NDEBUG is defined the default BOOST_ASSERT disappears as well. :-) This
can be overriden by


but it's better to make it 'just work.'

> Also
> BOOST_DEBUG doesn't do anything if BOOST_ASSERT is defined.

True, the nested #ifdefs may need to be reversed so that BOOST_ASSERT is
forcibly redefined to ((void)0) when BOOST_DEBUG is not defined.

In general the intent is that BOOST_DEBUG puts boost libraries in debug
mode, i.e. it may influence more than just BOOST_ASSERT.

If we decide that this is not necessary BOOST_ASSERT will simply fall back

> Another possible variant of BOOST_ASSERT is to have a macro that supplies
> message that is display instead of the expression. It would look like:
> BOOST_ASSERT_MSG( IsOpen(), "The caller should open the file." ) ;

This is usually accomplished with the

BOOST_ASSERT( IsOpen() && "The caller should open the file." ) ;

trick but a separate macro may be preferable.

Peter Dimov
Multi Media Ltd.

Boost list run by bdawes at, gregod at, cpdaniel at, john at