Checksum: 24385 Lines: 27 Path: utzoo!lsuc!sq!msb From: msb@sq.uucp (Mark Brader) Date: Sat, 20-Feb-88 19:42:15 EST Message-ID: <1988Feb20.194215.25242@sq.uucp> Newsgroups: comp.lang.c Subject: ctl(c) macro Summary: ctl('c') References: <11879@brl-adm.ARPA> Reply-To: msb@sq.UUCP (Mark Brader) Organization: SoftQuad Inc., Toronto > #define ctl(c) ('c'&037) This is a well-known nonportability. Substitution within string and character constants was a feature of certain versions of the C compiler (including many UNIX versions) that was documented only in the README file in the source directory for the compiler! If it had been generally announced, e.g. in K&R, it might have made it into the ANSI standard, but as it never was announced, it is best considered a common *bug*. There are arguments in favor of it and against it. The stringizing operator was the ANSI subcommittee's invention, a different way to get that functionality, but it is also nonportable to most existing systems. > I have come up with some ugly fixes, but would like to know: what is > the Right Way to do this? Don't turn what looks like a variable (namely c) into a constant. Say #define CTL(c) ((c) & 037) and use CTL('c') Okay? Mark Brader, SoftQuad Inc., Toronto, utzoo!sq!msb, msb@sq.com #define MSB(type) (~(((unsigned type)-1)>>1))