Path: utzoo!mnetor!uunet!husc6!necntc!ima!haddock!karl From: karl@haddock.ISC.COM (Karl Heuer) Newsgroups: comp.lang.c Subject: Re: macros with parameters in MSC 5.0 Message-ID: <2645@haddock.ISC.COM> Date: 19 Feb 88 18:01:49 GMT References: <11879@brl-adm.ARPA> <7277@brl-smoke.ARPA> Reply-To: karl@haddock.ima.isc.com (Karl Heuer) Organization: Interactive Systems, Boston Lines: 23 In article <7277@brl-smoke.ARPA> gwyn@brl.arpa (Doug Gwyn (VLD/VMB) ) writes: >In article <11879@brl-adm.ARPA> jbaker@ee.UCLA.EDU (Joe Baker) writes: >>#define ctl(c) ('c'&037) > >Yes, whoever did this was deliberately violating the K&R rules I looked it up when I first saw this hack, and I concluded that K&R didn't establish an unambiguous rule. The book says that macros are not expanded inside strings, but I don't think it specifies whether macro *arguments* are expanded inside strings within the macro. >With ANSI C, or any C preprocessor that includes the stringizing >feature, you can make the original usage work by > #define ctl(c) (#c[0]&037) >which would cause > case ctl(G): >to expand to > case ("G"[0]&037): Umm, I believe that according to the C rules, that's a non-constant expression (and hence illegal as a case label). Karl W. Z. Heuer (ima!haddock!karl or karl@haddock.isc.com), The Walking Lint