From 729c0a73bfee29dd4392f26e9f10b874e5b24137 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Wed, 8 Dec 2021 19:16:16 +0200 Subject: [PATCH 10/10] Replace AC_C_VARARRAYS use with reintroduced FC_C99_VARIABLE_ARRAYS AC_C_VARARRAYS is too strict about full compliance, when freeciv build requires only some compliance. This broke e.g. build with tcc. In S2_6 and earlier branches, our own AC_C99_VARIABLE_ARRAYS did just the correct checks for freeciv build. Reintroduce our own macro, now named as FC_C99_VARIABLE_ARRAYS, and use it instead of AC_C_VARARRAYS. See osdn #43352 Signed-off-by: Marko Lindqvist --- configure.ac | 7 +------ m4/c99.m4 | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/configure.ac b/configure.ac index 99fbe1065a..edfe7636be 100644 --- a/configure.ac +++ b/configure.ac @@ -619,12 +619,7 @@ dnl check profiling FC_GPROF FC_C99_VARIADIC_MACROS - -AC_C_VARARRAYS -if test "x$ac_cv_c_vararrays" != "xyes" ; then - AC_MSG_ERROR([A compiler supporting C99 variable arrays is required]) -fi - +FC_C99_VARIABLE_ARRAYS FC_C99_INITIALIZERS FC_C99_STDINT_H diff --git a/m4/c99.m4 b/m4/c99.m4 index 163872a460..2434500831 100644 --- a/m4/c99.m4 +++ b/m4/c99.m4 @@ -21,6 +21,30 @@ AC_DEFUN([FC_C99_VARIADIC_MACROS], fi ]) + +# Check C99-style variable-sized arrays (required) +# We don't use AC_C_VARARRAYS() as it's stricter than what we need +# and want - it would leave out compilers that are just fine for freeciv +# compilation. +# +# char concat_str[strlen(s1) + strlen(s2) + 1]; +# +AC_DEFUN([FC_C99_VARIABLE_ARRAYS], +[ + dnl Check for variable arrays + AC_CACHE_CHECK([for C99 variable arrays], + [ac_cv_c99_variable_arrays], + [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#include +#include +]], [[char *s1 = "foo", *s2 = "bar"; + char s3[strlen(s1) + strlen(s2) + 1]; + sprintf(s3, "%s%s", s1, s2);]])],[ac_cv_c99_variable_arrays=yes],[ac_cv_c99_variable_arrays=no])]) + if test "x${ac_cv_c99_variable_arrays}" != "xyes"; then + AC_MSG_ERROR([A compiler supporting C99 variable arrays is required]) + fi +]) + # Check C99-style initializers (required): # # Examples: -- 2.33.0