1dnl @synopsis AX_EMPTY_ARRAY
2dnl
3dnl Define EMPTY_ARRAY_SIZE to be either "0"
4dnl or "" depending on which syntax the compiler
5dnl prefers for empty arrays in structs.
6dnl
7dnl @version
8dnl @author James Yonan <jim@yonan.net>
9AC_DEFUN([AX_EMPTY_ARRAY], [
10	AS_VAR_PUSHDEF([VAR],[ax_cv_c_empty_array])dnl
11	AC_CACHE_CHECK(
12		[for C compiler empty array size],
13		[VAR],
14		[AC_COMPILE_IFELSE(
15			[AC_LANG_PROGRAM(
16				,
17				[[
18struct { int foo; int bar[0]; } mystruct;
19				]]
20			)],
21			[VAR=0],
22			[AC_COMPILE_IFELSE(
23				[AC_LANG_PROGRAM(
24					,
25					[[
26struct { int foo; int bar[]; } mystruct;
27					]]
28				)],
29				[VAR=],
30				[AC_MSG_ERROR([C compiler is unable to creaty empty arrays])]
31			)]
32		)]
33	)dnl
34	AC_DEFINE_UNQUOTED(
35		[EMPTY_ARRAY_SIZE],
36		[$VAR],
37		[Dimension to use for empty array declaration]
38	)dnl
39	AS_VAR_POPDEF([VAR])dnl
40])
41