Boost logo

Boost :

From: Markus Schöpflin (markus.schoepflin_at_[hidden])
Date: 2005-07-14 11:15:07


Hello,

I have the following macro code:

#define PY_DEFINE_CONSTANT(X) scope().attr(#X) = X

#define PY_DEFINE_CONSTANTS_HELPER(R, DATA, X) PY_DEFINE_CONSTANT(X);
#define PY_DEFINE_CONSTANTS(SEQ) \
BOOST_PP_SEQ_FOR_EACH(PY_DEFINE_CONSTANTS_HELPER, BOOST_PP_EMPTY, SEQ)

This works fine when used with non-macro arguments:

   PY_DEFINE_CONSTANTS((foo)(bar))

expands to:

   scope().attr("foo") = foo; scope().attr("bar") = bar;

But when foo and bar are macros like this:

   #define foo 1
   #define bar 2

it expands to:

   scope().attr("1") = 1; scope().attr("2") = 2;

Is there a way to get this:

   scope().attr("foo") = 1; scope().attr("bar") = 2;

or this:

   scope().attr("foo") = foo; scope().attr("bar") = bar;

IOW, how can I prevent macro expansion for X when invoked from
PY_DEFINE_CONSTANTS()?

TIA, Markus


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