This one bit me today

Morris M. Keesan keesan at bbn.com
Sat Oct 14 07:24:30 AEST 1989


In article <9999 at cbnews.ATT.COM> smk at cbnews.ATT.COM (Stephen M. Kennedy writes
> p.s. In another article, did someone say it was ok to define an abs macro as
>      -(x)?  What about "y = -abs(x);"?

But -(x) is not the entire body of the macro.  The macro was
#define ABS(x) ((x) < 0 ? -(x) : (x))
and in this context, -(x) is fine and doesn't need to be (-(x)), because the
whole macro has an outer set of parentheses.
------------------------------------------------------------------------------
Morris M. Keesan                    |
Internet: keesan at bbn.com            |
UUCP: Figure it out from the path   |



More information about the Comp.lang.c mailing list