C
cman
What are the mechanics involved in the calculation of an offset of a
structure member, demonstrated in this piece of code?
#define list_entry(ptr, type, member) \
((type *)((char *)(ptr)-(unsigned long)(&((type *)0)->member)))
Suppose you have struct foobar and want to compute the offset of
element boo, this is how it is done:
(unsigned long)(&((struct foobar *)0)->boo)
What does memory address 0 refer to?
cman
structure member, demonstrated in this piece of code?
#define list_entry(ptr, type, member) \
((type *)((char *)(ptr)-(unsigned long)(&((type *)0)->member)))
Suppose you have struct foobar and want to compute the offset of
element boo, this is how it is done:
(unsigned long)(&((struct foobar *)0)->boo)
What does memory address 0 refer to?
cman