Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!wuarchive!zaphod.mps.ohio-state.edu!samsung!uunet!taumet!steve From: steve@taumet.com (Stephen Clamage) Newsgroups: comp.lang.c Subject: Re: Using Macros Message-ID: <393@taumet.com> Date: 9 Aug 90 15:32:56 GMT References: <362.26be9dcc@astro.pc.ab.com> <21057@grebyn.com> Organization: Taumetric Corporation, San Diego Lines: 20 ckp@grebyn.com (Checkpoint Technologies) writes: [ shows how to make up a macro with expressions, rather than statements ] >Now this technique won't work if you really need multiple "statements", >which could include things like return, break, if, while, etc., but it >works just dandy for multiple expressions. Actually, you can handle "if" statements by transforming them into conditional expressions (c ? expr1 : expr2). As long as neither the "then" nor "else" clause contains "for", "while", "switch", "break", or "goto", you can always do this, though it is occasionally awkward. (I don't claim that you will always want to, just that you can.) If there is no "else", just use zero for the second expression. You will usually need to cast each expression to void to satisfy the constraint of the conditional expression that each half must evaluate to the same type. -- Steve Clamage, TauMetric Corp, steve@taumet.com