Preprocessor question
Doug Gwyn
gwyn at smoke.BRL.MIL
Thu Jan 19 23:26:42 AEST 1989
In article <531 at ole.UUCP> ray at ole.UUCP (Ray Berry) writes:
>#define VAL 3
>#define STR(x) #x
> puts("val is " STR(VAL));
> Turbo C produces "3" for STR(VAL); Microsoft produces "VAL" and
>leaves it at that.
> Which behavior is correct?
"Before being substituted, each argument's preprocessing tokens are
completely macro replaced as if they formed the rest of the
translation unit; no other preprocessing tokens are available."
So VAL is first expanded to 3 then the #3 is performed to produce
"3".
More information about the Comp.lang.c
mailing list