Can pre-ANSI C Preprocessor handle symbolic constants in strings?
Brumley David M
dlbres14 at pc.usl.edu
Sat Jun 1 19:03:12 AEST 1991
In article <1991May31.154937.24240 at csrd.uiuc.edu> bliss at sp64.csrd.uiuc.edu (Brian Bliss) writes:
> the following work on a sun and most other non-ANSI cpp's:
>
> #define quote(x) "x"
>
This doesn't work on the compiler in question (Laser C on an Atari
ST, admittedly not a canonical compiler) which doesn't substitute for
quoted arguments. The C compiler on our university's Pyramid-90x
running OSx4.1 does the substitution (and hence is less compliant with
ANSI than the PC compiler), but only once. So that with:
#define CONSTANT 42
#define quote(x) "x"
printf(quote(CONSTANT));
we get
printf("CONSTANT");
not
printf("42");
In any case this is all academic without string concatenation.
--
David M. Brumley
<dmb8516 at usl.edu>
More information about the Comp.lang.c
mailing list