Path: utzoo!attcan!uunet!yale!mfci!karzes From: karzes@mfci.UUCP (Tom Karzes) Newsgroups: comp.lang.c Subject: Re: Unnecessary Parenthesis Keywords: Use 'em all the time in macros... Message-ID: <481@m3.mfci.UUCP> Date: 26 Jul 88 15:34:25 GMT References: <2089@ssc-vax.UUCP> <441@kaon.uchicago.edu> <1401@devsys.oakhill.UUCP> Sender: root@mfci.UUCP Reply-To: karzes@mfci.UUCP (Tom Karzes) Organization: Multiflow Computer Inc., Branford Ct. 06405 Lines: 18 Summary: Expires: Sender: Followup-To: Distribution: In article <1401@devsys.oakhill.UUCP> steve@oakhill.UUCP (steve) writes: }I'm sorry I can't include the text I'm mentioning since I'm haveing net }reply problems, but I'll fake it as best I can. }In an absolute sense }> #define square(x) (x * x) }shouldn't be : }> #define square(x) ((x) * (x)) }it should be : }> #define square(x) (temp = (x),(temp * temp)) }in order to avoid problems with sending in a post incremented variable; This doesn't work in general in C for a number of reasons. First, C is not an expression language, so you can't declare temp to be local to the expression. This means it has to either be global or defined by the client (and of course, this requires fixing its type, but I won't complain about that). Second, even if you could declare it locally, you'd have to be careful about the name you used to avoid a name conflict with a variable used in the expression for x.