This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Volatile constants?
- To: Erik Mouw <J dot A dot K dot Mouw at its dot tudelft dot nl>
- Subject: Re: Volatile constants?
- From: Alasdair Baird <alasdair at wildcat dot demon dot co dot uk>
- Date: Wed, 29 Mar 2000 18:49:04 +0100 (BST)
- Cc: 97nv46 at skola dot kiruna dot se, gcc at gcc dot gnu dot org
- References: <s8e219aa.038@ymer><200003291530.RAA06981@duteinh.et.tudelft.nl>
> > #define abs2(x) (x<0 ? -x : x)
>
> <nitpick>
> You should define this as:
>
> #define abs2(x) ((x) < 0 ? (-x) : (x))
>
> Rationale: see what happens with your version if you use abs2(2 - 3). The
> extra parentesis enforce the correct operator precedence.
I think that you might find the following to actually be correct though:
#define abs2(x) ((x) < 0 ? -(x) : (x))