1 # Check for variable-length arrays.
7 # Copyright (C) 2001, 2009-2015 Free Software Foundation, Inc.
8 # This file is free software; the Free Software Foundation
9 # gives unlimited permission to copy and/or distribute it,
10 # with or without modifications, as long as this notice is preserved.
12 # This is a copy of AC_C_VARARRAYS from a recent development version
13 # of Autoconf. It replaces Autoconf's version, or for pre-2.61 autoconf
14 # it defines the macro that Autoconf lacks.
15 AC_DEFUN([AC_C_VARARRAYS],
17 AC_CACHE_CHECK([for variable-length arrays],
19 [AC_EGREP_CPP([defined],
20 [#ifdef __STDC_NO_VLA__
24 [ac_cv_c_vararrays='no: __STDC_NO_VLA__ is defined'],
27 [[/* Test for VLA support. This test is partly inspired
28 from examples in the C standard. Use at least two VLA
29 functions to detect the GCC 3.4.3 bug described in:
30 http://lists.gnu.org/archive/html/bug-gnulib/2014-08/msg00014.html
32 #ifdef __STDC_NO_VLA__
37 int fvla (int m, int C[m][m]);
40 simple (int count, int all[static count])
42 return all[count - 1];
46 fvla (int m, int C[m][m])
48 typedef int VLA[m][m];
51 static int (*q)[m] = &B;
53 return C && &x[0][0] == &D[0] && &D[0] == s[0];
57 [ac_cv_c_vararrays=yes],
58 [ac_cv_c_vararrays=no])])])
59 if test "$ac_cv_c_vararrays" = yes; then
60 dnl This is for compatibility with Autoconf 2.61-2.69.
61 AC_DEFINE([HAVE_C_VARARRAYS], 1,
62 [Define to 1 if C supports variable-length arrays.])
63 elif test "$ac_cv_c_vararrays" = no; then
64 AC_DEFINE([__STDC_NO_VLA__], 1,
65 [Define to 1 if C does not support variable-length arrays, and
66 if the compiler does not already define this.])