# define container_of (PTR, type, member) ({\
Const typeof ((0) (type *) - & gt; Member) * __mptr=(PTR); \
(type *) ((char *) __mptr - offsetof (type, member)); })
My question is, why not just use PTR - offsetof (type, member), but to the other __mptr=(PTR), and then use __mptr - offsetof (type, member),
CodePudding user response:
__mptr=(PTR) can be used for type testing, if the incoming PTR type error, can be detected in the compilation phase directly,