Need macro to get offset within a structure
Doug Gwyn
gwyn at smoke.brl.mil
Wed Feb 20 10:35:38 AEST 1991
In article <ENAG.91Feb19131201 at holmenkollen.ifi.uio.no> enag at ifi.uio.no (Erik Naggum) writes:
>#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
What I would recommend is to key on __STDC__, #including <stddef.h>
in a Standard C environment and using a definition like that one in
other environments. It should work in most non-standard C environments
(but not all of them!).
More information about the Comp.lang.c
mailing list