This one bit me today

Conor P. Cahill cpcahil at virtech.UUCP
Sat Oct 7 22:19:26 AEST 1989


In article <1067 at polari.UUCP>, 6sigma at polari.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)

And they will also parenthesize the entire expression:

#define xavg(m)		((sum + 3) / (m))

to ensure that there are no problems with evaluation order.
-- 
+-----------------------------------------------------------------------+
| Conor P. Cahill     uunet!virtech!cpcahil      	703-430-9247	!
| Virtual Technologies Inc.,    P. O. Box 876,   Sterling, VA 22170     |
+-----------------------------------------------------------------------+



More information about the Comp.lang.c mailing list