From 9bd2f223f6c07e2b3723a37a426f52852f84ba54 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Mon, 14 Feb 2022 00:28:29 +0200 Subject: [PATCH 44/44] configure: Add check for C99 compound literals Requested by alienvalkyrie See osdn #43855 Signed-off-by: Marko Lindqvist --- configure.ac | 1 + m4/c99.m4 | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/configure.ac b/configure.ac index 253883a2dd..5e64c16703 100644 --- a/configure.ac +++ b/configure.ac @@ -752,6 +752,7 @@ FC_C_FLAGS([-Werror -Wall], [], [WERROR_TEST_FLAGS]) FC_C99_VARIADIC_MACROS FC_C99_VARIABLE_ARRAYS FC_C99_INITIALIZERS +FC_C99_COMPOUND_LITERALS FC_C99_STDINT_H FC_INITIALIZER_BRACES diff --git a/m4/c99.m4 b/m4/c99.m4 index 2434500831..235d2653f9 100644 --- a/m4/c99.m4 +++ b/m4/c99.m4 @@ -75,6 +75,26 @@ AC_DEFUN([FC_C99_INITIALIZERS], fi ]) +# Check C99-style compound literals (required): +# +AC_DEFUN([FC_C99_COMPOUND_LITERALS], +[ + dnl Check for C99 compound literals + AC_CACHE_CHECK([for C99 compound literals], + [ac_cv_c99_compound_literals], + [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[struct foo { + int a; char *b; float c; }; + void foobar(struct foo *); + ]], + [[struct foo bar; + bar = (struct foo) {.b = "text", .c = 0.1 }; + foobar(&bar);]])], [ac_cv_c99_compound_literals=yes], + [ac_cv_c99_compound_literals=no])]) + if test "${ac_cv_c99_compound_literals}" != "yes"; then + AC_MSG_ERROR([A compiler supporting C99 compound literals is required]) + fi +]) + # Check C99-style stdint.h (required) AC_DEFUN([FC_C99_STDINT_H], [ -- 2.34.1