In Pintos project, there is a macro that converting pointer like what I wrote in title.
#define list_entry(LIST_ELEM, STRUCT, MEMBER)
((STRUCT *) ((uint8_t *) &(LIST_ELEM)->next
- offsetof (STRUCT, MEMBER.next)))
(at src/lib/kernel/list.h)
Why It is not like this?
#define list_entry(LIST_ELEM, STRUCT, MEMBER)
((STRUCT *) ((uint8_t *)LIST_ELEM
- offsetof (STRUCT, MEMBER)))