typecheck code
Sri Ram Vemulpali
sri.ram.gmu06 at gmail.com
Mon Jan 31 12:03:37 EST 2011
Hi all,
/*
* Check at compile time that something is of a particular type.
* Always evaluates to 1 so you may use it easily in comparisons.
*/
#define typecheck(type,x) \
({ type __dummy; \
typeof(x) __dummy2; \
(void)(&__dummy == &__dummy2); \
1; \
})
#define typecheck_fn(type,function) \
({ typeof(type) __tmp = function; \
(void)__tmp; \
})
Can anyone help me, explain the above code typecheck. How does
(void)(&__dummy == &__dummy2) evaluates to 1
I appreciate any explain.
--
Regards,
Sri.
More information about the Kernelnewbies
mailing list