Possible Duplicate:
Rationale behind the container_of macro in linux/list.h
#define container_of(ptr, type, member) ({ \
const typeof( ((type *)0)->member ) *__mptr = (ptr); \
(type *)( (char *)__mptr - offsetof(type,member) );})\
Why do we need to construct mptr
here instead of casting ptr
directly to a char*
?