EDIT now works for any type, not just pointers
Something more or less removed from the Linux kernel using the GCC extension typeof().
This generates a warning at compile time, it also works for integer pointer types
#define CHECK(a, b) do { \
typeof(a) _a; \
typeof(b) _b; \
(void) (&_a == &_b); \
} while (0)
int main(int argc, char **argv)
{
int *foo;
int *bar;
char *baz;
CHECK(foo, bar);
CHECK(bar, baz);
return 0;
}
source
share