It seems that FreeBSD provides _Alignof and _Alignas macros in
various standard header files, including <stddef.h>. Since the
configure probes don't include any headers, these are missed,
resulting in conflicting macro definitions.
To fix this, all we really need to do is include some header
file in the test program, so these system versions are visible
when testing for _Alignas and _Alignof support.
#
# Probe whether the C compiler understands _Alignof(T).
#
#
# Probe whether the C compiler understands _Alignof(T).
#
+# Some implementations (e.g., FreeBSD 9) define a usable _Alignof macro
+# in <stddef.h> (and other headers), so we can use that if available.
+#
# If not supported, _Alignof(T) is defined as a function-like macro which
# uses offsetof to guess the alignment of T, which must be a type such that
# If not supported, _Alignof(T) is defined as a function-like macro which
# uses offsetof to guess the alignment of T, which must be a type such that
-# T x; is a valid declaration of x as an object of type T. It is therefore
-# necessary that the caller includes <stddef.h> before using _Alignof.
+# T x; is a valid declaration of x as an object of type T.
+#
+# For these reasons, callers should #include <stddef.h> before using _Alignof.
#
# We skip the test if Autoconf has previously determined that the C compiler
# supports C11 or a newer standard, since the C11 test program checks this.
#
# We skip the test if Autoconf has previously determined that the C compiler
# supports C11 or a newer standard, since the C11 test program checks this.
[AS_CASE([${ac_cv_prog_cc_c11-no}/${ac_prog_cc_stdc-no}],
[no/no|*/c89|*/c99],
[AC_CACHE_CHECK([if $CC supports _Alignof], [dx_cv_have_alignof],
[AS_CASE([${ac_cv_prog_cc_c11-no}/${ac_prog_cc_stdc-no}],
[no/no|*/c89|*/c99],
[AC_CACHE_CHECK([if $CC supports _Alignof], [dx_cv_have_alignof],
- [AC_COMPUTE_INT([_dx_tmp], [_Alignof(char)], [@&t@], [_dx_tmp=0])
+ [AC_COMPUTE_INT([_dx_tmp], [_Alignof(char)], [#include <stddef.h>
+], [_dx_tmp=0])
AS_CASE([$_dx_tmp], [1], [dx_cv_have_alignof=yes], [dx_cv_have_alignof=no])])],
[dx_cv_have_alignof=yes])
AS_CASE([$dx_cv_have_alignof], [no], [AC_DEFINE([_Alignof(T)],
AS_CASE([$_dx_tmp], [1], [dx_cv_have_alignof=yes], [dx_cv_have_alignof=no])])],
[dx_cv_have_alignof=yes])
AS_CASE([$dx_cv_have_alignof], [no], [AC_DEFINE([_Alignof(T)],
#
# Probe whether the C compiler understands _Alignas(X).
#
#
# Probe whether the C compiler understands _Alignas(X).
#
+# Some implementations (e.g., FreeBSD 9) define a usable _Alignas macro
+# in <stddef.h> (and other headers), so we can use that if available. For
+# this reason, callers should #include <stddef.h> before using _Alignas.
+#
# If not supported, but the compiler supports the GNU __attribute__ or
# Microsoft __declspec methods to set alignment, _Alignas(X) is defined
# as a function-like macro which expands to such syntax. These only
# If not supported, but the compiler supports the GNU __attribute__ or
# Microsoft __declspec methods to set alignment, _Alignas(X) is defined
# as a function-like macro which expands to such syntax. These only
do
AC_COMPUTE_INT([_dx_tmp],
[sizeof (struct { char a; char ALIGNAS_TEST(4) b; }) >= 8],
do
AC_COMPUTE_INT([_dx_tmp],
[sizeof (struct { char a; char ALIGNAS_TEST(4) b; }) >= 8],
- [#define ALIGNAS_TEST(X) $_dx_alignas
+ [#include <stddef.h>
+#define ALIGNAS_TEST(X) $_dx_alignas
],[_dx_tmp=0])
AS_CASE([$_dx_tmp/$_dx_alignas],
[1/_Alignas*], [dx_cv_have_alignas=yes; break],
],[_dx_tmp=0])
AS_CASE([$_dx_tmp/$_dx_alignas],
[1/_Alignas*], [dx_cv_have_alignas=yes; break],