offsetof
Dag-Erling Smørgrav
des at des.no
Fri Apr 1 07:04:41 PST 2005
I noticed that our definition of offsetof (in <sys/cdefs.h>) is as
follows:
#define __offsetof(type, field) ((size_t)(&((type *)0)->field))
This definition is gratuitously unportable (it assumes that a null
pointer is all-bits-zero). A better definition would be the
following:
#define __offsetof(type, field) \
((size_t)((char *)&((type *)0)->field - (char *)(type *)0))
DES
--
Dag-Erling Smørgrav - des at des.no
More information about the freebsd-standards
mailing list