What is a constant expression

Norman Diamond diamond at csl.sony.co.jp
Mon Oct 23 12:11:38 AEST 1989


In article <727 at lakart.UUCP> dg at lakart.UUCP (David Goodenough) writes:

[regarding ANSIfying the CTRL(c) macro]

>Flame away if you wish, just try it first.

I can't.  I don't have a validated (or even unvalidated-but-asserted)
ANSI C compiler.  Nonetheless I do finally have a copy of the proposed
standard, which in fact is a legal one.  (Thanks Steve Friedl.)

>#define	prequote(x) 'x
>#define postquote(x) x'

I do not believe that this can possibly work in ANSI C.  Consider the
following tweaks:

#define prequote(x)  'x /* is this a comment? */
#define postquote(x) x' /* is this a comment? */

>#define	CNTL(c) ((postquote(prequote(c))) & 0x1f)
>
>CNTL(c)

Now what is the character constant?  A single character?  A longer
string?  (with implementation-defined results, especially when it's
longer than the number of chars that fit in an int...)

>Bletch :-/

True, but that's not the problem at the moment.

(In case anyone missed it, the real question is, can that solution
really possibly work in ANSI C?)

-- 
Norman Diamond, Sony Corp. (diamond%ws.sony.junet at uunet.uu.net seems to work)
  Should the preceding opinions be caught or     |  James Bond asked his
  killed, the sender will disavow all knowledge  |  ATT rep for a source
  of their activities or whereabouts.            |  licence to "kill".



More information about the Comp.std.c mailing list