Bogus warning from AIX XL C Compiler/6000?
Ronald S. Woan
ron at woan.austin.ibm.com
Fri Aug 24 01:56:52 AEST 1990
In article <1990Aug23.034343.11444 at murdoch.acc.Virginia.EDU>,
mms7r at 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 at peyote.cactus.org or woan at soda.berkeley.edu +
+ other email addresses Prodigy: XTCR74A Compuserve: 73530,2537 +
More information about the Comp.unix.aix
mailing list