bengsig@dk.oracle.com (Bjorn Engsig) (02/21/91)
In article <1991Feb16.232713.6001@runx.oz.au>, Richard Murnane writes: |Does anybody know a decent macro to find the offset of an element |in a structure And in article <ENAG.91Feb19131201@holmenkollen.ifi.uio.no> enag@ifi.uio.no (Erik Naggum) replied: |#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) |This works like a charm on a vast number of compilers I've used. Actually, ANSI C includes an offsetof macro in <stddef.h>. And please do not enter the usual discussion of wheather the macro definition above is valid ANSI C or not. The rationale of the ANSI C will fill you in with the details of this. -- Bjorn Engsig, ORACLE Corporation, E-mail: bengsig@oracle.com, bengsig@oracle.nl "Stepping in others footsteps, doesn't bring you ahead"