Re: cpp macros: quotes and spaces (# and ##)
Je 1999/08/27(5)/19:08, joost witteveen montris sian geniecon skribante:
> 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"
[What doesn't work:]
> #define NEXT_STAT next_ ## WRAP_STAT
[..]
> #define QUOTE(a) #a
> #define WRAP_STAT_QUOTE QUOTE(WRAP_STAT)
[..]
OK, if everything else fails, read the docs. So, now I finally found
(in cpp.info, `Argument Prescan') how to do it. Still, I'd very much
like to hear if anyone knows how portable this is:
#define WRAP_STAT __xstat
#define NEXT_STAT(a,b,c) (CONCAT_LEVEL(WRAP_STAT))(a,b,c)
#define CONCAT_LEVEL(X) CONCAT(X)
#define CONCAT(X) next_ ## X
NEXT_STAT(1,2,3)
#define WRAP_STAT_QUOTE QUOTE_LEVEL(WRAP_STAT)
#define QUOTE_LEVEL(x) QUOTE_MACRO(x)
#define QUOTE_MACRO(y) #y
WRAP_STAT_QUOTE
(at least for GNU cpp it works!)
> (Please also reply to me in person, as I am not subscribed to this
> list).
--
joostje
Reply to: