#define container_of(ptr, type, member) ({ \
const typeof( ((type *)0)->member ) *__mptr = (ptr); \
(type *)( (char *)__mptr - offsetof(type,member) );})
我已经知道第一行用于类型检查,但对于第二行,为什么要进行(char *)
转换?我没有找到解释。
我自己做了一些实验代码,即使没有转换,结果似乎也很好。