Reputation: 367
What's the significance of (void) (&_max1 == &_max2); in the following definition of max found in Linux/tools/lib/lockdep/uinclude/linux/kernel.h?
#define max(x, y) ({ \
typeof(x) _max1 = (x); \
typeof(y) _max2 = (y); \
(void) (&_max1 == &_max2); \
_max1 > _max2 ? _max1 : _max2; })
Upvotes: 3
Views: 250
Reputation: 2881
It helps the compiler detect invalid uses of max()
, i.e. with non-comparable x
and y
. As Sukminder points out, the ==
check is only used at compile time, it doesn't end up in the resulting binary.
Upvotes: 1