Mail Archives: djgpp/1999/02/28/21:07:25
Paul Derbyshire wrote:
> Can Nate make this work without side effect problems?
>
> #define MAX(a,b) (((a) > (b)) ? (a) : (b))
I can, but in order not to reinvent the wheel I'll use RMS's code
(section "Naming an expression's type" from /Using and Porting GNU CC/)
#define max(a,b) \
({typedef _ta = (a), _tb = (b); \
_ta _a = (a); _tb _b = (b); \
_a > _b ? _a : _b; })
Gotta love those GCC extensions. (Okay, so it won't work in ANSI C.
Can you write a single function or macro in it, or ANSI C++, that will
safely find the maximum of two arguments of any types?)
--
Nate Eldredge
nate AT cartsys DOT com
- Raw text -