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 <equi...@opensourcerouting.org> --- 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 Quagga-dev@lists.quagga.net https://lists.quagga.net/mailman/listinfo/quagga-dev