Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uwm.edu!cs.utexas.edu!uunet!kddlab!titcca!sragwa!wsgw!socslgw!diamond From: diamond@csl.sony.co.jp (Norman Diamond) Newsgroups: comp.std.c Subject: Re: What is a constant expression Message-ID: <10983@riks.csl.sony.co.jp> Date: 23 Oct 89 02:11:38 GMT References: <1219@crdos1.crd.ge.COM> <727@lakart.UUCP> Reply-To: diamond@ws.sony.junet (Norman Diamond) Organization: Sony Computer Science Laboratory Inc., Tokyo, Japan Lines: 39 In article <727@lakart.UUCP> dg@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@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".