Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!wuarchive!uunet!taumet!steve From: steve@taumet.com (Stephen Clamage) Newsgroups: comp.lang.c Subject: Re: Using Macros Message-ID: <395@taumet.com> Date: 9 Aug 90 16:34:43 GMT References: <14339@shlump.nac.dec.com> <14404@diamond.BBN.COM> <12318@hydra.gatech.EDU> Organization: Taumetric Corporation, San Diego Lines: 24 gg10@prism.gatech.EDU (GALLOWAY) writes: >Why doesn't this work? >#define A_MACRO(bar, baz) func1(bar), func2(baz) >I have been using syntax like this for awhile, is this wrong or unportable? You need an extra set of parens: #define A_MACRO(bar, baz) ( func1(bar), func2(baz) ) Look what happens without the parens: i = A_MACRO(3, 4) + 2; becomes: i = func1(3), func2(4) + 2; which is the same as (i = func1(3)), (func2(4) + 2); which is probably not what was meant. With parens, it becomes; i = (func1(3), func2(4)) + 2; which may or may not be what was meant, but at least the +2 is not discarded. If the do { ... } while(0) construct was used instead, the above expression becomes illegal, which may or may not be what was intended. -- Steve Clamage, TauMetric Corp, steve@taumet.com