The file include/linux/typecheck.h
of the Linux kernel contains this code:
/*
* Check at compile time that 'function' is a certain type, or is a pointer
* to that type (needs to use typedef for the function type.)
*/
#define typecheck_fn(type,function)
({ typeof(type) __tmp = function;
(void)__tmp;
})
I am familiar with GNU C’s compound statement expression and typeof
. From what I know, a pointer to a function of one type may be converted to a pointer to a function of another type and back again; the result shall compare equal to the original pointer, so even if the types are different, the assignment should be okay.
But what is the last line doing? It appears to look like a NO-OP to me.
Would the above somehow fail to compile, or merely raise a diagnostic message unless -Werror
was specified?
7