
aliasing quotes in macros?
Quote:
> Ordinarily the C preprocessor doesn't perform macro expansions
> within quoted strings. But what if you have an application in which
> you DO want the preprocessor to perform a macro expansion within a
> string?
> For example:
> typedef enum {
> VALUE_1,
> VALUE_2,
> VALUE_3
> } my_enumtype;
> #define MY_MACRO(parm) printf("the value of parm is %d", parm);
> main () {
> MY_MACRO(VALUE_1);
> }
> The output i'd like to see is:
> the value of VALUE_1 is 0
> But because the preprocessor won't expand the first occurrance of
> parm (per K&R page 86), the actual output of this macro is:
> the value of parm is 0
> Anybody know a clever trick for faking out the preprocessor so it
> will do this?
#define MY_MACRO(parm) printf("the value of " #parm " is %d", parm)
Michael M Rubenstein