Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!uflorida!travis!brad From: brad@SSD.CSD.HARRIS.COM (Brad Appleton) Newsgroups: comp.lang.c Subject: Re: Using Macros Summary: Sorry! Message-ID: <650@travis.csd.harris.com> Date: 9 Aug 90 17:55:04 GMT References: <642@travis.csd.harris.com> <17298@haddock.ima.isc.com> <46860@brunix.UUCP> Sender: news@travis.csd.harris.com Organization: Harris Computers Systems Division, Fort Lauderdale,FL Lines: 27 In article <46860@brunix.UUCP> gvr@cs.brown.edu (George V. Reilly) writes: >! % #define CHECK(cond) { if (cond) exit(-1); } >! % could be replaced by >! % #define CHECK(cond) ((cond) || exit(-1)) >! % >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. Actually, it was the IF statement I messed up, not the "||". I want the program to exit only if the condition is false (like an assertion). Sorry about that! I was more concerned with illustrating a (possibly new) technique and didnt pay close enough attention to the example I used. The dup2() macro that I posted in the same article I have used before (succesfully). Actually, that dup2() macro is in a small piece of code that I wrote specifically for illustrating how to fork off a process and have the parent read the output from the child. It seems to be asked frequently (even though it is Unix specific). Should I submit my file to the FAQ list? ______________________ "And miles to go before I sleep." ______________________ Brad Appleton brad@travis.ssd.csd.harris.com Harris Computer Systems ...!uunet!hcx1!brad Fort Lauderdale, FL USA ~~~~~~~~~~~~~~~~~~~~ Disclaimer: I said it, not my company! ~~~~~~~~~~~~~~~~~~~