Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!romp!auschs!awdprime!woan.austin.ibm.com!ron From: ron@woan.austin.ibm.com (Ronald S. Woan) Newsgroups: comp.unix.aix Subject: Re: Bogus warning from AIX XL C Compiler/6000? Keywords: correct under ANSI definition Message-ID: <3239@awdprime.UUCP> Date: 23 Aug 90 15:56:52 GMT References: <1990Aug23.034343.11444@murdoch.acc.Virginia.EDU> Sender: news@awdprime.UUCP Reply-To: @cs.utexas.edu:ibmchs!auschs!woan.austin.ibm.com!ron Followup-To: comp.unix.aix Organization: Austin School of Hardknocks Lines: 35 In article <1990Aug23.034343.11444@murdoch.acc.Virginia.EDU>, mms7r@krebs.acc.Virginia.EDU (Mitch Smith) writes: Mitch> Problem: The character constant in the following short program Mitch> produces a bogus warning. Mitch> /* test1.c */ main() { int c; Mitch> c = '\x'; printf("c = %c\n", c); exit(0); } Mitch> ..............a.. a - 1506-235: (W) Illegal escape sequence x Mitch> ignored. $ Mitch> In fact, 'x' is not ignored. When executed, the Mitch> compiled program prints "c = x". Mitch> According to K&R (1978), page 181, under the section on Mitch> character constants: "If the character following a Mitch> backslash is not one of those specified, the backslash is Mitch> ignored." [The "specified" escape sequences being '\n', Mitch> '\t', etc.] Yes, get the new ANSI edition of K&R. On page 193: "If the character following the \ is not one of those specified, the behavior is undefined." And actually, 'x' just happens to have been defined for specifying constants in hex, i.e. '\x07' is the bell. You should thank your lucky stars that you got the right output or the fact that IBM has tried to be as backwards compatible as possible, so they only gave you a very good warning message with an indication of what it was going to do with it. Anyway, this doesn't seem like something you should be trying to do anyway, afterall what's wrong with c='x'? Ron +-----All Views Expressed Are My Own And Are Not Necessarily Shared By------+ +------------------------------My Employer----------------------------------+ + Ronald S. Woan @cs.utexas.edu:ibmchs!auschs!woan.austin.ibm.com!ron + + alternatives woan@peyote.cactus.org or woan@soda.berkeley.edu + + other email addresses Prodigy: XTCR74A Compuserve: 73530,2537 +