The macro offsetof (defined in
#include struct S{ int a; int b; void * p;};int main(){ int n = offsetof(S, a); // 0 n = offsetof(S, p); //8}
Note that offsetof works with POD (Plain Old Data) structs and POD unions. The result of applying the offsetof macro to a field that is a static data member or a function member is undefined.