See I wasn’t aware of offsetof.
Its really good.
Its defined as:
#define offsetof(s,m) (size_t)&reinterpret_cast<const volatile char&>(((s *)0)->m)
So when you do:
offsetof( STRUCT_TYPE, MEMBER_NAME )
You really get:
So its pretty neat. Basically what happens is, you get the number of bytes that MEMBER_NAME is from the beginning of the struct. .. refers to the address of member m in this object. Since the start address of this object is 0 (NULL), the address of member m is exactly the offset.
PRETTY cool. I can’t believe I’ve been listing numerical byte counts for this long..
and the hand of experience.