changeset 21446:822dc5a202c9

build: Fix C11 compliance detection to work with clang * prog_c.m4 (OCTAVE_PROG_CC_C11): Use offsetof macro to provide an integral constant expression that can be evaluated at compile-time to work with stricter compilers (e.g. clang).
author Mike Miller <mtmiller@octave.org>
date Mon, 14 Mar 2016 13:06:59 -0700
parents de155ca994d4
children ac1e50cfc9ed
files m4/prog_c.m4
diffstat 1 files changed, 7 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/m4/prog_c.m4	Sun Mar 13 08:46:59 2016 -0700
+++ b/m4/prog_c.m4	Mon Mar 14 13:06:59 2016 -0700
@@ -32,6 +32,7 @@
 AC_DEFUN([OCTAVE_PROG_CC_C11],
 [_OCTAVE_C_STD_TRY([c11],
 [_OCTAVE_C_C99_TEST_HEADER[
+#include <stddef.h>
 // Check _Alignas.
 char _Alignas (double) aligned_as_double;
 char _Alignas (0) no_special_alignment;
@@ -81,7 +82,12 @@
 [_OCTAVE_C_C99_TEST_BODY[
   v1.i = 2;
   v1.w.k = 5;
-  _Static_assert (&v1.i == &v1.w.k, "Anonymous union alignment botch");
+  // FIXME: Octave-specific change, this feature test is modified from the
+  // original Autoconf source. The address-of operator is not an integral
+  // constant expression and cannot be used with _Static_assert.
+  _Static_assert (offsetof(struct anonymous, i)
+                  == offsetof(struct anonymous, w.k),
+                  "Anonymous union alignment botch");
 ]],
 dnl Try
 dnl GCC		-std=gnu11 (unused restrictive mode: -std=c11)