7

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); ?

BЈовић
  • 62,405
  • 41
  • 173
  • 273

1 Answers1

8

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
rom1v
  • 2,752
  • 3
  • 21
  • 47