ANSI C defines the offsetof() macro
in <stddef.h> ,
which lets you compute
the offset of field f in struct s
as
offsetof(struct s, f) .
If for some reason you have to code this sort of thing yourself,
one possibility is
#define offsetof(type, f) ((size_t) /
((char *)&((type *)0)->f - (char *)(type *)0))