Why compare the address in this min implementation?

The implementation of the 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 is this: (void) (&_min1 == &_min2); ?

+7
c
source share
1 answer

It generates a warning if x and y are of different types:

 int i; long j; (void) (&i == &j); 

The compiler says:

 warning: comparison of distinct pointer types lacks a cast 
+8
source share

All Articles