Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!cs.utexas.edu!uunet!taumet!steve From: steve@taumet.com (Stephen Clamage) Newsgroups: comp.lang.c Subject: Re: Preprocessor macro to quote its argument Message-ID: <405@taumet.com> Date: 21 Aug 90 15:03:38 GMT References: <1112@mti.mti.com> <1114@mti.mti.com> <1990Aug20.012839.3545@zoo.toronto.edu> <11517@ogicse.ogi.edu> Organization: Taumetric Corporation, San Diego Lines: 27 schaefer@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. The #define must consist of valid *pre-processor* tokens, which are not quite identical to C language tokens. In particular, partial string constants and partial character constants are not allowed. That is, your examples such as of #define w " #define x abc" #define y ' #define z d' are all illegal in ANSI C. (Preprocessor tokens include fragments of file names in unexpanded #include directives, and fragments of numbers in macro definitions.) The "stringizing" and "token concatenation" preprocessor operators are sufficient to do what the nonportable earlier constructs did, except for building a character constant. There are now no legal tricks in an ANSI-compliant program which allow you to build a character constant from parts. You could write to the ANSI committee and suggest that the next C standard (1995?) include "character-constant pasting" :-) -- Steve Clamage, TauMetric Corp, steve@taumet.com