xref: /netbsd-src/external/gpl2/diffutils/dist/m4/vararrays.m4 (revision 75f6d617e282811cb173c2ccfbf5df0dd71f7045)
1# Check for variable-length arrays.
2
3#serial 1
4
5# From Paul Eggert
6
7# Copyright (C) 2001 Free Software Foundation, Inc.
8
9# This program is free software; you can redistribute it and/or modify
10# it under the terms of the GNU General Public License as published by
11# the Free Software Foundation; either version 2, or (at your option)
12# any later version.
13
14# This program is distributed in the hope that it will be useful,
15# but WITHOUT ANY WARRANTY; without even the implied warranty of
16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17# GNU General Public License for more details.
18
19# You should have received a copy of the GNU General Public License
20# along with this program; if not, write to the Free Software
21# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
22# 02111-1307, USA.
23
24AC_DEFUN([AC_C_VARARRAYS],
25[
26  AC_CACHE_CHECK([for variable-length arrays],
27    ac_cv_c_vararrays,
28    [AC_TRY_COMPILE(
29       [],
30       [static int x; char a[++x]; a[sizeof a - 1] = 0; return a[0];],
31       ac_cv_c_vararrays=yes,
32       ac_cv_c_vararrays=no)])
33  if test $ac_cv_c_vararrays = yes; then
34    AC_DEFINE(HAVE_C_VARARRAYS, 1,
35      [Define to 1 if C supports variable-length arrays.])
36  fi
37])
38