offsetof
offsetof is a macro defined in the C standard library header stddef.h. It yields the offset, in bytes, of a named member within a structure or union, relative to the beginning of that type. The result has type size_t and is intended for compile-time calculation of a member’s position in memory. A typical implementation is the expression ((size_t) &(((type *)0)->member)), which forms the address of the member as if the object at address zero were laid out with that member, then casts it to size_t.
Usage example: struct S { int a; char b; }; size_t off_b = offsetof(struct S, b); // often 4 on
Portability and limitations: The macro is defined for standard-layout types, and the value is a compile-time