From: Michael Olbrich Date: Wed, 25 Apr 2012 10:16:58 +0200 Subject: [PATCH] fix AC_CHECK_ALIGNOF when cross-compiling with gcc >= 4.5 Signed-off-by: Michael Olbrich --- lib/autoconf/types.m4 | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/autoconf/types.m4 b/lib/autoconf/types.m4 index 9f482da..15fa603 100644 --- a/lib/autoconf/types.m4 +++ b/lib/autoconf/types.m4 @@ -800,8 +800,12 @@ m4_define([_AC_CHECK_ALIGNOF], _AC_CACHE_CHECK_INT([alignment of $1], [AS_TR_SH([ac_cv_alignof_$3])], [(long int) offsetof (ac__type_alignof_, y)], [AC_INCLUDES_DEFAULT([$2]) -#ifndef offsetof -# define offsetof(type, member) ((char *) &((type *) 0)->member - (char *) 0) +#if __GNUC_PREREQ(4,0) +# define offsetof(type, member) __builtin_offsetof(type, member) +#else +# ifndef offsetof +# define offsetof(type, member) ((char *) &((type *) 0)->member - (char *) 0) +# endif #endif typedef struct { char x; $1 y; } ac__type_alignof_;], [if test "$AS_TR_SH([ac_cv_type_$3])" = yes; then