Boost logo

Boost :

From: Paul Mensonides (pmenso57_at_[hidden])
Date: 2005-07-15 04:41:43


> -----Original Message-----
> From: boost-bounces_at_[hidden]
> [mailto:boost-bounces_at_[hidden]] On Behalf Of Markus Schöpflin

> I see and I'm amazed, as usual when dealing with the preprocessor. :-)

Note, BTW, if arbitrary token-pasting of any two preprocessing tokens was
well-defined, you could do it without the interface intrusion. With C99's
placemarkers, you can do it with minimal intrusion:

PY_DEFINE_CONSTANTS((foo)(bar),)

> > This is about the best way that you can do it, but I won't
> guarantee
> > that it will work on buggy preprocessors. In fact, I know it won't
> > work on VC. The timing is tricky, and it's intrusive on the
> > interface, but that's about the only way that it can be done.
>
> Fortunately I don't have to use MSVC, but you are right, the
> interface doesn't really look nice. I think I'll have to make
> a little poll at the office on what's better:
>
> PY_DEFINE_CONSTANT(foo);
> PY_DEFINE_CONSTANT(bar);
>
> or
>
> PY_DEFINE_CONSTANTS((foo)(bar) BOOST_PP_INTERCEPT_)
>
> Maybe we'll just stick with the simple macro then.

You don't have to use BOOST_PP_INTERCEPT_. You just need something that 1)
expands to nothing when a specific thing is pasted to it and 2) doesn't defer
macro expansion. For the latter, it means that it can't be concatenated to the
left side of 'seq'. E.g. it could be as simple as:

#define PY_DEFINE_CONSTANTS(seq) \
    ... seq ## 0xPY_DEFINE_CONSTANTS_UNDERSCORE ... \
    /**/

#define _0xPY_DEFINE_CONSTANTS_UNDERSCORE

PY_DEFINE_CONSTANTS((foo)(bar)_)

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