<stddef.h> - alternative definition of offsetof for gcc using builtin

This commit is contained in:
Ben Gras 2010-08-25 07:25:32 +00:00
parent 50ca7f7f8f
commit 1d0e0e217d

View file

@ -6,7 +6,11 @@
#include <sys/null.h>
/* The following is not portable, but the compiler accepts it. */
#ifdef __GNUC__
#define offsetof(type, ident) __builtin_offsetof (type, ident)
#else
#define offsetof(type, ident) ((size_t) (unsigned long) &((type *)0)->ident)
#endif
#if _EM_PSIZE == _EM_WSIZE
typedef int ptrdiff_t; /* result of subtracting two pointers */