Path: utzoo!utgpu!water!watmath!clyde!att!pacbell!ames!umd5!mimsy!oddjob!kaon!arthur!paul From: paul@arthur.uchicago.edu (Paul Burchard) Newsgroups: comp.lang.c Subject: Re: Unnecessary Parenthesis Keywords: Use 'em all the time in macros... Message-ID: <441@kaon.uchicago.edu> Date: 21 Jul 88 13:06:09 GMT References: <2089@ssc-vax.UUCP> Sender: root@kaon.uchicago.edu Reply-To: paul@zaphod.UChicago.Edu (Paul Burchard) Organization: Dept. of Mathematics, Univ. of Chicago Lines: 30 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. Consider: > >#define Square(x) x*x >#define GetNextChar(c) c = getchar() > [...] >The above two macros should have been written like: > >#define Square(x) (x)*(x) >#define GetNextChar(c) (c = getchar()) > [...] >~ David Geary, Boeing Aerospace, ~ >~ Seattle - "THE DRIZZLE CAPITAL OF THE WORLD" ~ Actually, they should have been written like #define Square(x) ((x)*(x)) #define GetNextChar(c) ((c) = getchar()) I trust you can imagine code that requires these further parens. ----------------------------------------------------------------------------- Paul Burchard paul@zaphod.UChicago.Edu enum Chicago_weather { roast, freeze, steam, dry, simmer } today; -----------------------------------------------------------------------------