Chris Antos wrote:
> in sysutil.h, Abs is defined as:
> 
>     #define Abs(a) ((a >= 0) ? a : (-a))
> 
> Doh!!!!  that's wrong.  the left paren should come after the minus sign, and
> there should be parens around the second "a":
> 
>     #define Abs(a) ((a >= 0) ? (a) : -(a))

Actually there should be parens around the first "a" too:
      #define Abs(a) (((a) >= 0) ? (a) : -(a))
My rule of thumb is to always put parens around EVERY occurence of a
macro argument in the expansion.  I've been bitten by this too many
times.
--Mark

Reply via email to