OFFSET -macro (also offsetof in ANSI-C)

Doug Gwyn gwyn at smoke.brl.mil
Wed Nov 28 05:29:10 AEST 1990


In article <898 at ehviea.ine.philips.nl> ncpg at ehviea.ine.philips.nl (ncpg) writes:
>#define	OFFSET(structPtr, field)	((unsigned short) \
>					(&((char *)(structPtr->field))) - \
>					&((char *)(structPtr)))

This wouldn't be right anyway.  It's &structPtr->field that you want to
use; you cannot apply & to the result of an object cast because it's not
an lvalue.



More information about the Comp.lang.c mailing list