Path: utzoo!utgpu!water!watmath!clyde!rutgers!uwvax!oddjob!hao!ames!nrl-cmf!cmcl2!brl-adm!brl-smoke!gwyn From: gwyn@brl-smoke.ARPA (Doug Gwyn ) Newsgroups: comp.lang.c Subject: Re: macros with parameters in MSC 5.0 Message-ID: <7309@brl-smoke.ARPA> Date: 22 Feb 88 03:09:25 GMT References: <11879@brl-adm.ARPA> <4099@hoptoad.uucp> Reply-To: gwyn@brl.arpa (Doug Gwyn (VLD/VMB) ) Organization: Ballistic Research Lab (BRL), APG, MD. Lines: 29 In article <4099@hoptoad.uucp> gnu@hoptoad.uucp (John Gilmore) writes: >jbaker@ee.UCLA.EDU (Joe Baker) wrote: >> #define ctl(c) ('c'&037) >This change caused us to have to fix more than 50 files in Berkeley >Unix. We wouldn't have minded changing all the macro definitions -- we >know that substitution inside strings is a hack -- it's that we had to >change all the CALLERS too that bugged us! >[Responses of the form: "Well, you already fixed your code, so why should >we make the standard reasonable?" are bogus. A useful capability was removed, >and replaced with a less capable set of features.] First, this was NOT a change to the C language. K&R already guaranteed that macro substitution would not occur inside string and character literals (section 12.1 of Appendix A). I daresay there are more instances of C compilers currently that do not do such substitution than those that do; generally only compilers adapted from AT&T's source (the Reiser C preprocessor in particular) have this bug. X3J11, realizing that the facility was nevertheless useful, designed an alternative approach that was compatible with the K&R definition. To see what is wrong with the Reiser method, try the following program: #include #define TEST(a,b) ((void)fprintf(stderr,"This is a test: 0x%x\n",(a)^(b))) main() { TEST(0xFF<<4,0xFFFF>>4); return 0; }