Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!uunet!mcsun!tuvie!vmars!hp From: hp@vmars.tuwien.ac.at (Peter Holzer) Newsgroups: comp.lang.c Subject: Re: Using Macros Message-ID: <1752@tuvie> Date: 9 Aug 90 16:23:55 GMT References: <362.26be9dcc@astro.pc.ab.com> <21057@grebyn.com> <642@travis.csd.harris.com> <17298@haddock.ima.isc.com> <46860@brunix.UUCP> <10881@crdgw1.crd.ge.com> Sender: news@tuvie Lines: 38 volpe@underdog.crd.ge.com (Christopher R Volpe) writes: >In article <46860@brunix.UUCP>, gvr@cs.brown.edu (George V. Reilly) writes: >|>Ah, but Karl, you missed the more important bug that Brad should have >|>used &&, not ||. In Brad's example, exit() will only be called if >|>cond == 0, which is exactly the inverse of what is desired. The same is >|>true of your second offering. >What makes you think that is what was desired? I interpret "CHECK(cond)" >the same way I interpret "ASSERT(cond)", which is "continue iff cond is true". >I.e., exit when cond is false. Under this interpretation, "||" is correct. What made ME think that this s what was desired is this line in the original posting: From: brad@SSD.CSD.HARRIS.COM (Brad Appleton) > > #define CHECK(cond) { if (cond) exit(-1); } > which is certainly not equivalent to: > > #define CHECK(cond) ((cond) || exit(-1)) > but to #define CHECK(cond) ((cond) && exit(-1)) Karl obviously interpreted it the same way or he would not have suggested: From: karl@haddock.ima.isc.com (Karl Heuer) > #define CHECK(cond) ((cond) ? exit(-1) : (void)0) It is amazing though, that the Walking Lint missed the ||-&& confusion. Oh well, the program would miss it too :-) -- | _ | Peter J. Holzer | Think of it | | |_|_) | Technische Universitaet Wien | as evolution | | | | | hp@vmars.tuwien.ac.at | in action! | | __/ | ...!uunet!mcsun!tuvie!vmars!hp | Tony Rand |