Newsgroups: comp.lang.c
Path: utzoo!henry
From: henry@zoo.toronto.edu (Henry Spencer)
Subject: Re: Preprocessor macro to quote its argument
Message-ID: <1990Aug21.175138.24633@zoo.toronto.edu>
Organization: U of Toronto Zoology
References: <1112@mti.mti.com> <1114@mti.mti.com> <1990Aug20.012839.3545@zoo.toronto.edu> <11517@ogicse.ogi.edu>
Date: Tue, 21 Aug 90 17:51:38 GMT

In article <11517@ogicse.ogi.edu> 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.

Your impression is wrong; the RHS of a #define constant must be a sequence
of valid preprocessor tokens (which are somewhat less restrictive than
"real" tokens).  In particular, mismatched quotes have undefined effects.

The right way to fix the notorious `CTRL(D)' problem is to quote the D.
There is no portable way for the macro to supply the (single) quotes.
This has been true for a long time; tokenizing preprocessors existed
well before the ANSI C effort started.
-- 
Committees do harm merely by existing. | Henry Spencer at U of Toronto Zoology
                       -Freeman Dyson  |  henry@zoo.toronto.edu   utzoo!henry
