The (char *) casting in container_of() macro in linux kernel

Viewed 1393
#define container_of(ptr, type, member) ({                      \
    const typeof( ((type *)0)->member ) *__mptr = (ptr);    \
    (type *)( (char *)__mptr - offsetof(type,member) );})

I already know that first line is for type checking, but for the second line,
Why do it do a (char *) casting? I find nowhere explain this.
And I do some experiment code myself, even without the casting, the result seems to be fine too.

1 Answers
Related