ANSI Parsing/Preproc questions
Ken Lerman
lerman at stpstn.UUCP
Tue Oct 16 21:44:42 AEST 1990
In article <383 at goya.dit.upm.es> esink at turia.dit.upm.es (Eric Wayne Sink) writes:
[...]
>#define macro(X) variX
>/* obviously, some operator is needed above, if this is legal at all
>*/
>
>macro(5) = 3; /* expands to: vari5 = 3 */
>
[...]
>Eric W. Sink
>esink at turia.dit.upm.es
Another post showed (I love it when I get to see the answers before I
see the questions) the use of the ANSI ## operator to do this.
Prior to ANSI, many compilers accepted:
#define macro(X) vari/**/X
to expand:
macro(5) = 3;
as:
vari5 = 3;
I don't know if this is "official" K&R or not, but it worked on a lot
of machines. (Note that the comment must be of zero length for this
to work.)
Ken
More information about the Comp.lang.c
mailing list