Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!wuarchive!gem.mps.ohio-state.edu!ginosko!uunet!hsi!mfci!karzes From: karzes@mfci.UUCP (Tom Karzes) Newsgroups: comp.lang.c Subject: Re: This one bit me today Message-ID: <1066@m3.mfci.UUCP> Date: 7 Oct 89 15:26:19 GMT References: <2432@hub.UUCP> <832@crdos1.crd.ge.COM> <1067@polari.UUCP> Sender: karzes@mfci.UUCP Reply-To: karzes@mfci.UUCP (Tom Karzes) Organization: Multiflow Computer Inc., Branford Ct. 06405 Lines: 26 In article <1067@polari.UUCP> 6sigma@.UUCP (Brian Matthews) writes: >That's why anyone who knows what they're doing will parenthesize each >argument in the expansion of the macro and use liberal whitespace, thusly: > >#define xavg(m) (sum + 3) / (m) > >Then things like xavg (*p) and xavg (x + y) work as expected. It's also why people who *really* know what they're doing parenthesize both the arguments and the top level of their expression macros, thusly: #define xavg(m) ((sum + 3) / (m)) Otherwise if you write something like: a / xavg(b) your buggy macro would give you: a / (sum + 3) / (b) rather than: a / ((sum + 3) / (b)) Which, as you can see, has an entirely different meaning.