http://gcc.gnu.org/onlinedocs/gcc/Typeof.html
typeof is a way to refer to the type of an expression, supported by gcc
e.g.#define max(a, b)\({typeof(a) _a = (a);\typeof(b) )_b =(b);\_a>_b?_a:_b;})
To declare y as an array of the same type as x:typeof (x) y[4];又如: #define pointer(T) typeof(T*)
e.g. to cast a member of a structure to the container structure
#define container_of(ptr, type, member) ({ \ const typeof(((type *)0)->member)) *__mptr = (阅读全文>
发表于 @ 2009年04月10日 12:55:00|评论(loading...)|编辑|举报|收藏