Messages in this thread | | | From | "Camiel Vanderhoeven" <> | Subject | RE: macro conflict | Date | Thu, 23 Aug 2001 21:42:52 -0400 |
| |
A small detail; you min(x,y) fails if x and y are pointers.
Example: min(char * a, char * b) would evaluate to char * __x = (a), __y = (b); etc...
Here __x is a pointer and __y is a char. A better solution (at least the one that has my vote so far) would besomething like this:
typeof(x) __x=(x); typeof(y) __y=(y); (__x < __y) ? __x : __y
Camiel.
> Without digging through the archives to see if this has already > been suggested (if so, I apologize), why can't the following be done: > > 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.) - 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/
| |