Newsgroups: comp.std.c Path: utzoo!henry From: henry@zoo.toronto.edu (Henry Spencer) Subject: Re: Macro substitution in character literals Message-ID: <1990Dec12.182455.20377@zoo.toronto.edu> Organization: U of Toronto Zoology References: <11323@pt.cs.cmu.edu> <11327@pt.cs.cmu.edu> <1990Dec10.173255.805@zoo.toronto.edu> <362@bksmel.oz.au> Date: Wed, 12 Dec 90 18:24:55 GMT In article <362@bksmel.oz.au> james@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@zoo.toronto.edu utzoo!henry