The implementation of min function here is done as:
#define min(x, y) ({ \
typeof(x) _min1 = (x); \
typeof(y) _min2 = (y); \
(void) (&_min1 == &_min2); \
_min1 < _min2 ? _min1 : _min2; })
What is the point of the 4th line?
Why do this: (void) (&_min1 == &_min2);
?
It generates a warning if x
and y
have different types:
int i;
long j;
(void) (&i == &j);
The compiler says:
warning: comparison of distinct pointer types lacks a cast
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With