I agree this is less surprising! I was looking at pretty much the exact same thing in the linux kernel on friday afternoon right as I walked out the door. Should we attribute the original author?
thanks! donald On Sat, Mar 12, 2016 at 1:58 PM, David Lamparter < [email protected]> wrote: > cf. https://gcc.gnu.org/onlinedocs/gcc/Typeof.html > (Works on all compilers on Quagga's compiler support list in > doc/overview.texi) > > Signed-off-by: David Lamparter <[email protected]> > --- > Would suggest this additional fix to make the macro less surprising. > > -David > > --- > lib/zebra.h | 12 +++++++++--- > 1 file changed, 9 insertions(+), 3 deletions(-) > > diff --git a/lib/zebra.h b/lib/zebra.h > index d980283..0ea5ee4 100644 > --- a/lib/zebra.h > +++ b/lib/zebra.h > @@ -373,10 +373,16 @@ struct in_pktinfo > > /* MAX / MIN are not commonly defined, but useful */ > #ifndef MAX > -#define MAX(a, b) ((a) > (b) ? (a) : (b)) > -#endif > +#define MAX(a, b) \ > + ({ typeof (a) _a = (a); \ > + typeof (b) _b = (b); \ > + _a > _b ? _a : _b; }) > +#endif > #ifndef MIN > -#define MIN(a, b) ((a) < (b) ? (a) : (b)) > +#define MIN(a, b) \ > + ({ typeof (a) _a = (a); \ > + typeof (b) _b = (b); \ > + _a < _b ? _a : _b; }) > #endif > > #define ZEBRA_NUM_OF(x) (sizeof (x) / sizeof (x[0])) > -- > 2.3.6 > > > _______________________________________________ > Quagga-dev mailing list > [email protected] > https://lists.quagga.net/mailman/listinfo/quagga-dev >
_______________________________________________ Quagga-dev mailing list [email protected] https://lists.quagga.net/mailman/listinfo/quagga-dev
