This is one of the series of macros in stddef.h.
#define offsetof(s,m) (size_t)&(((s *)0)->m)
What does (s *)0 mean?
It is a way of writing a NULL
pointer of type pointer-to-s
. By taking the address of the m
member of an s
whose address is 0, you get the offset of m
within an s
.
It's a typecast, converting 0
to pointer to s
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With