cpp macros: quotes and spaces (# and ##)
I've got a define
#define WRAP_STAT __xstat
and from the macro WRAP_STAT, I want to define
#define NEXT_STAT next___xstat
and
#define WRAP_STAT_QUOTE "__xstat"
To define NEXT_STAT in terms of WRAP_STAT, I tried
#define NEXT_STAT next_ ## WRAP_STAT
(with the ## to get rid of the space in between next_ and __xstat).
But this doesn't work, as apparently cpp takes everything after ##
literally, and now NEXT_STAT is defined ad next_WRAP_STAT.
Does anyone know how to remove the space, and make cpp expand
the macro WRAP_STAT?
The other, WRAP_STAT_QUOTE, also seems difficult. I tried
#define QUOTE(a) #a
#define WRAP_STAT_QUOTE QUOTE(WRAP_STAT)
but then again, cpp fails to expand the WRAP_STAT, resulting
in effectively
#define WRAP_STAT "WRAP_STAT"
not exactly what I wanted.
Does anyone have a way to fix that?
(Please also reply to me in person, as I am not subscribed to this
list).
joostje
Reply to: