[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [MiNT] compiling problem



> > #define min(a,b)	(((a) < (b)) ? (a) : (b))
> 
> Either a or b are evaluated twice here, which does not happen with the
> current one. If you write code like:
> 
>  m = min(a++, b++);
> 
> you expect a and b to be increased with 1. One of them will be
> increased with 2, if you use your simple macro.

Thats it!   I knew it was something like that but I couldn't remember.
One way is simpler and sometimes faster if your compiler doesn't
optimize it well, but prone to that exact problem that the other one
doesn't have.