Saturday, 31 August 2013

How to understand "((size_t) &((TYPE *)0)->MEMBER)"?

How to understand "((size_t) &((TYPE *)0)->MEMBER)"?

the codes in linux-2.6.16/include/linux/stddef.h is:
#undef offsetof
#ifdef __compiler_offsetof
#define offsetof(TYPE,MEMBER) __compiler_offsetof(TYPE,MEMBER)
#else
#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)

No comments:

Post a Comment