Messages in this thread |  | | Date | Fri, 24 Aug 2001 01:35:38 +0200 | | From | Roman Zippel <> | | Subject | Re: macro conflict |
| |
Hi,
"Magnus Naeslund(f)" wrote:
> > min(x,y) = ({typeof((x)) __x=(x), __y=(y); (__x < __y) ? __x : __y}) > > > > That gets you the correct "evaluate the args once" semantics and gives > > you control over typing (the comparison is done in the type of the > > first argument) and we don't have to change a zillion drivers. > > > > (typeof() is a gcc extension.)
({...}) is also gcc extension.
> But then again, how do you know it's the type of x we want, maybe we want > type of y, that is and signed char (not an int like x). > Talk about hidden buffer overflow stuff :)
That's the reason I'm using this macro for affs:
#define MIN(a, b) ({ \ typeof(a) _a = (a); \ typeof(b) _b = (b); \ _a < _b ? _a : _b; \ })
I need a very good reason to use something else, so far I'm unconvinced.
bye, Roman - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
|  |