Preprocessor macro to quote its argument
Henry Spencer
henry at zoo.toronto.edu
Wed Aug 22 03:51:38 AEST 1990
In article <11517 at ogicse.ogi.edu> schaefer at ogicse.ogi.edu (Barton E. Schaefer) writes:
>Now wait a minute here -- is it really true that the "right hand side"
>of a #define constant must be a valid token sequence? I was under the
>impression that only the result after expansion had to be a valid sequence.
Your impression is wrong; the RHS of a #define constant must be a sequence
of valid preprocessor tokens (which are somewhat less restrictive than
"real" tokens). In particular, mismatched quotes have undefined effects.
The right way to fix the notorious `CTRL(D)' problem is to quote the D.
There is no portable way for the macro to supply the (single) quotes.
This has been true for a long time; tokenizing preprocessors existed
well before the ANSI C effort started.
--
Committees do harm merely by existing. | Henry Spencer at U of Toronto Zoology
-Freeman Dyson | henry at zoo.toronto.edu utzoo!henry
More information about the Comp.lang.c
mailing list