Macro substitution in character literals
Henry Spencer
henry at zoo.toronto.edu
Thu Dec 13 05:24:55 AEST 1990
In article <362 at bksmel.oz.au> james at bksmel.UUCP (James Crawford) writes:
>>>| ... I'd like to be able to write something like:
>>>| #define chr(c) 'c' /* Yes, this is incorrect */
>>>... I'd like the result to be potentially usable as a value
>>>in compile-time initialization expressions...
>>
>> Can't be done.
>
>I think for ANSI C compilers you should be able to get around this with
>token pasteing.
Nope. Token pasting pastes *tokens* together. An isolated single quote
may or may not be a valid preprocessor token -- ANSI C behavior is
explicitly undefined when you try to treat ' or " as a pp-token.
--
"The average pointer, statistically, |Henry Spencer at U of Toronto Zoology
points somewhere in X." -Hugh Redelmeier| henry at zoo.toronto.edu utzoo!henry
More information about the Comp.std.c
mailing list