Path: utzoo!attcan!uunet!lll-winken!lll-tis!ames!pacbell!att!ihnp4!ihlpf!nevin1 From: nevin1@ihlpf.ATT.COM (00704a-Liber) Newsgroups: comp.lang.c Subject: Re: Unnecessary Parenthesis Keywords: Use 'em all the time in macros... Message-ID: <5291@ihlpf.ATT.COM> Date: 14 Jul 88 15:32:13 GMT References: <2089@ssc-vax.UUCP> Reply-To: nevin1@ihlpf.UUCP (00704a-Liber,N.J.) Organization: AT&T Bell Laboratories - Naperville, Illinois Lines: 28 In article <2089@ssc-vax.UUCP> dmg@ssc-vax.UUCP (David Geary) writes: >"Unnecessary" parenthesis are something I use all the time in macro >definitions, also. Most of the parentheses in macros ARE necessary as you have shown (but are usually not sufficient as I will show). >Consider: >#define Square(x) x*x [David shows why this macro should be redefined as #define Square(x) ((x)*(x)) ] but consider the case where you try the following: int x; x = 2; (void)printf("The square of %d + 1 is %d.\n", x, Square(++x)); The Square macro does not work correctly because the argument has side effects (this is why parentheses are not sufficient in macros). -- _ __ NEVIN J. LIBER ..!att!ihlpf!nevin1 (312) 510-6194 ' ) ) You are in a little twisty maze of / / _ , __o ____ email paths, all different. / (_