Boost logo

Boost :

From: John Torjo (john.lists_at_[hidden])
Date: 2003-07-19 11:40:48


> On the other hand, perhaps you have a use case that clearly demonstrates
the
> need for BOOST_HAS_CURRENT_FUNCTION?

The SMART_ASSERT library clearly needs it.

The idea is: when an assertion fails, in case BOOST_CURRENT_FUNCTION holds a
meaningful value, I want to show it. Otherwise, not.

Testing for "(unknown)" seems pretty ugly.

Here's what I do now:

// thanks Pavel Vozenilek!
// based on boost/current_function.hpp
namespace boost { namespace smart_assert { namespace Private {

// note: I need the BOOST_SMART_ASSERT_FUNCTION_EXISTS macro, in order
// to know if I add the BOOST_SMART_ASSERT_FUNCTION to the context or not
inline void current_function_helper() // SGI's __FUNCSIG__ requires this
{

#define BOOST_SMART_ASSERT_FUNCTION_EXISTS

#if defined(__GNUC__) || (defined(__MWERKS__) && (__MWERKS__ >= 0x3000))
# define BOOST_SMART_ASSERT_FUNCTION __PRETTY_FUNCTION__
#elif defined(__FUNCSIG__)
# define BOOST_SMART_ASSERT_FUNCTION __FUNCSIG__
#elif defined(__BORLANDC__) && (__BORLANDC__ >= 0x550)
# define BOOST_SMART_ASSERT_FUNCTION __FUNC__
#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901)
# define BOOST_SMART_ASSERT_FUNCTION __func__
#elif (defined BOOST_MSVC) && (__MSC_VER >= 1300)
# define BOOST_SMART_ASSERT_FUNCTION __FUNCDNAME__
#elif defined(__IBMCPP__) && (__IBMCPP__ <= 500)
# define BOOST_SMART_ASSERT_FUNCTION __FUNCTION__
#elif (defined __HP_aCC) && (__HP_aCC <= 33300)
# define BOOST_SMART_ASSERT_FUNCTION __FUNCTION__
#else
# undef BOOST_SMART_ASSERT_FUNCTION_EXISTS

#endif

} } } } // namespaces

// the context surrounding the assertion
#ifdef BOOST_SMART_ASSERT_FUNCTION_EXISTS
    #define SMART_ASSERT_CONTEXT
context("file",BOOST_SMART_ASSERT_FILE).context("line",__LINE__).context(BOO
ST_SMART_ASSERT_FUNCTION_KEY,BOOST_SMART_ASSERT_FUNCTION)
#else
    #define SMART_ASSERT_CONTEXT
context("file",BOOST_SMART_ASSERT_FILE).context("line",__LINE__)
#endif

I would really like the BOOST_HAS_CURRENT_FUNCTION macro. Thanks.

Best,
John

>
> _______________________________________________
> Unsubscribe & other changes:
http://lists.boost.org/mailman/listinfo.cgi/boost
>


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