Preprocessor macro to quote its argument
R. Kym Horsell
vu0310 at bingvaxu.cc.binghamton.edu
Mon Aug 20 17:49:42 AEST 1990
In article <1990Aug19.200440.8534 at uunet!unhd> al at unhd.UUCP (Anthony Lapadula) writes:
\\\
>What happens if Q is ``invoked'' with another macro as its argument, as in:
> #define M1 100
> #define M2 func()
> :
> puts (Q(M1));
> puts (Q(M2));
>
>What should the output be? The two compilers available to me disagree.
> gcc version 1.37.1 ---> outputs "M1" and "M2"
> cc ---> CPP error ("#100 undefined [in puts(#100)])
The #x in a macro is supposed to produce an ascii string if its
argument "x".
Since rescanning occurs *after* this process and ANSII C isn't
*supposed* to look inside strings you should get what gcc gave
you.
It sounds like your cc dosn't comply with the std.
-Kym Horsell
More information about the Comp.lang.c
mailing list