From bdd80be1fed0f4b3956246a44082a4226362074d Mon Sep 17 00:00:00 2001 From: Alon Bar-Lev Date: Wed, 29 Feb 2012 22:11:54 +0200 Subject: [PATCH] build: m4/ax_emptyarray.m4: cleanup Signed-off-by: Alon Bar-Lev Acked-by: David Sommerseth Signed-off-by: David Sommerseth --- m4/ax_emptyarray.m4 | 49 ++++++++++++++++++++++++++++----------------- 1 file changed, 31 insertions(+), 18 deletions(-) diff --git a/m4/ax_emptyarray.m4 b/m4/ax_emptyarray.m4 index 0a8755cf..c6781c17 100644 --- a/m4/ax_emptyarray.m4 +++ b/m4/ax_emptyarray.m4 @@ -7,21 +7,34 @@ dnl dnl @version dnl @author James Yonan AC_DEFUN([AX_EMPTY_ARRAY], [ - AC_MSG_RESULT([checking for C compiler empty array support]) - AC_COMPILE_IFELSE([AC_LANG_SOURCE( - [ - struct { int foo; int bar[[0]]; } mystruct; - ])], [ - AC_DEFINE_UNQUOTED(EMPTY_ARRAY_SIZE, 0, [Dimension to use for empty array declaration]) - ], [ - AC_COMPILE_IFELSE([AC_LANG_SOURCE( - [ - struct { int foo; int bar[[]]; } mystruct; - ])], [ - AC_DEFINE_UNQUOTED(EMPTY_ARRAY_SIZE,, [Dimension to use for empty array declaration]) - ], [ - AC_MSG_ERROR([C compiler is unable to creaty empty arrays]) - ]) - ]) - ] -) + AS_VAR_PUSHDEF([VAR],[ax_cv_c_empty_array])dnl + AC_CACHE_CHECK( + [for C compiler empty array size], + [VAR], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + , + [[ +struct { int foo; int bar[0]; } mystruct; + ]] + )], + [VAR=0], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + , + [[ +struct { int foo; int bar[]; } mystruct; + ]] + )], + [VAR=], + [AC_MSG_ERROR([C compiler is unable to creaty empty arrays])] + )] + )] + )dnl + AC_DEFINE_UNQUOTED( + [EMPTY_ARRAY_SIZE], + [$VAR], + [Dimension to use for empty array declaration] + )dnl + AS_VAR_POPDEF([VAR])dnl +])