Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!deejay!gear!cadlab!staff From: staff@cadlab.sublink.ORG (Alex Martelli) Newsgroups: comp.lang.c Subject: Re: Using Macros Message-ID: <248@cadlab.sublink.ORG> Date: 12 Aug 90 21:38:54 GMT References: <362.26be9dcc@astro.pc.ab.com> <21057@grebyn.com> <642@travis.csd.harris.com> Organization: CAD.LAB, Bologna, Italia Lines: 22 brad@SSD.CSD.HARRIS.COM (Brad Appleton) writes: ...[some details omitted]... >use of the logical operators || and &&. Using this, the following: > #define CHECK(cond) { if (cond) exit(-1); } >could be replaced by > #define CHECK(cond) ((cond) || exit(-1)) >And wouldnt wreak havoc inside nested if statements. Another technique I like for this very situation: #define CHECK(cond) if(cond) exit(-1); else ...no havoc-wrecking here, either, and also work fine for cases where the conditional action is, say, "return FAILURE_INDICATOR;" - AND no lint complaints about constants in conditional contexts. Only good for CONDITIONAL macros, alas... -- Alex Martelli - CAD.LAB s.p.a., v. Stalingrado 45, Bologna, Italia Email: (work:) staff@cadlab.sublink.org, (home:) alex@am.sublink.org Phone: (work:) ++39 (51) 371099, (home:) ++39 (51) 250434; Fax: ++39 (51) 366964 (work only; any time of day or night).