Summary: minor, provide C11 check for anonymous structs
authorSebastian Freundt <hroptatyr@fresse.org>
Sun, 1 Jan 2012 20:56:47 +0000 (20:56 +0000)
committerSebastian Freundt <hroptatyr@fresse.org>
Sun, 1 Jan 2012 20:56:47 +0000 (20:56 +0000)
Keywords: bldchn

This changeset provides a check for anon structs, an on-and-off feature
of gcc, and mandatory for C11 support.

* m4/sxe-compiler.m4 (SXE_CHECK_ANON_STRUCTS): simply check if anon
  structs are possible, they ought to be when -std=gnu1x is selected but
  that's only possible in gcc 4.6.1 it seems.

Signed-off-by: Sebastian Freundt <hroptatyr@fresse.org>
m4/sxe-compiler.m4

index c42974a..64a7342 100644 (file)
@@ -1761,4 +1761,38 @@ AC_DEFUN([SXE_CC_LIBRARY_LOCATION], [dnl
        popdef([LIBNAME])
 ])dnl SXE_CC_LIBRARY_LOCATION
 
+
+AC_DEFUN([SXE_CHECK_ANON_STRUCTS], [
+       AC_MSG_CHECKING([whether C compiler can cope with anonymous structures])
+       AC_LANG_PUSH(C)
+       AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+union __test_u {
+       int i;
+       struct {
+               char c;
+               char padc;
+               short int pads;
+       };
+};
+       ]], [[
+       union __test_u tmp = {.c = '4'};
+       ]])], [
+               sxe_cv_have_anon_structs="yes"
+       ], [
+               sxe_cv_have_anon_structs="no"
+       ])
+       AC_MSG_RESULT([${sxe_cv_have_anon_structs}])
+
+       if test "${sxe_cv_have_anon_structs}" = "yes"; then
+               AC_DEFINE([HAVE_ANON_STRUCTS], [1], [
+                       Whether c1x anon structs work])
+               $1
+               :
+       else
+               $2
+               :
+       fi
+       AC_LANG_POP()
+])dnl SXE_CHECK_ANON_STRUCTS
+
 dnl sxe-compiler.m4 ends here