Unnecessary Parenthesis
Paul Burchard
paul at arthur.uchicago.edu
Thu Jul 21 23:06:09 AEST 1988
In article <2089 at ssc-vax.UUCP> dmg at 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 at zaphod.UChicago.Edu
enum Chicago_weather { roast, freeze, steam, dry, simmer } today;
-----------------------------------------------------------------------------
More information about the Comp.lang.c
mailing list