ANSI C and comment preprocessing

Henry Spencer henry at zoo.toronto.edu
Fri Jan 18 10:31:06 AEST 1991


In article <3303 at unisoft.UUCP> greywolf at unisoft.UUCP (The Grey Wolf) writes:
>If comments are expanded to spaces, this kind of breaks things like
>
>#define	operate_with(x) \
>	dbm_put(p->pw_/**/e); \
>	munge_data(p->pw_/**/e, munge_factor[1]); \
>	login->pw_/**/e = p->pw_/**/e;
>
>doesn't it?

This macro is already broken; even before ANSI C, there were many C compilers
that wouldn't do what you're expecting with it.

>How does ANSI token-pasting work? (DON'T say RTFM because I don't *have*
>TFM!)  Is is something similar to what I've provided above as an example?

No.  This revolting kludge has been flushed, in favor of a language feature
that doesn't rely so heavily on implementation accidents.  "##" is the
ANSI C token-concatenation operator.
-- 
If the Space Shuttle was the answer,   | Henry Spencer at U of Toronto Zoology
what was the question?                 |  henry at zoo.toronto.edu   utzoo!henry



More information about the Comp.lang.c mailing list