>From: "Paul Mensonides" <[EMAIL PROTECTED]>

> From: "Terje Slettebų" <[EMAIL PROTECTED]>
>
> > 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

Yes, I realised that after I had sent it. It was mostly a quick fix, to show
what was intended. I later simplified it to:

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

This is because I didn't need macro expansion of the arguments, before
stringizing, after all. However, I used BOOST_STRINGIZE in the posting, as
it might be useful in the general case.

>(and do you mean BOOST_PP_STRINGIZE?):

I wasn't aware of that BOOST_STRINGIZE isn't guaranteed to work. Perhaps
that should be fixed?

> #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)        \
>     /**/

Thanks for the fix.


Regards,

Terje

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

Reply via email to