Boost logo

Boost :

From: Paul Mensonides (pmenso57_at_[hidden])
Date: 2002-12-31 23:13:01


----- Original Message -----
From: "Terje Slettebø" <tslettebo_at_[hidden]>

> To do that (without changing the Boost unit test code), I made a few
> forwarding macros, like this:
>
> #define BOOST_CHECK_EQUAL_CP(a,b)\
>
>
BOOST_CHECKPOINT("BOOST_CHECK_EQUAL("##BOOST_STRINGIZE(a)##","##BOOST_STRING
> IZE(b)##")");\
> BOOST_CHECK_EQUAL(a,b)

1) BOOST_STRINGIZE(a) will not *legally* expand. (It looks like the type of
thing that Metrowerks will expand anyway though.) In any case,
token-pasting happens prior to rescanning the replacement list, so the
concatenations happen first. Which...

2) ...is undefined behavior: token-pasting yields multiple tokens.
Depending on how a particular preprocessor handles this, it might actually
cause BOOST_STRINGIZE to expand. What you want is this:

Fix: remove the concatenation operators. This will yield adjacent strings
which will already get concatenated (and do you mean BOOST_PP_STRINGIZE?):

#define BOOST_CHECK_EQUAL_CP(a, b) \
    BOOST_CHECKPOINT( \
        "BOOST_CHECK_EQUAL(" \
        BOOST_PP_STRINGIZE(a) \
        "," \
        BOOST_PP_STRINGIZE(b) \
        ")" \
    ); \
    BOOST_CHECK_EQUAL(a, b) \
    /**/

Regards,
Paul Mensonides


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