diff --git a/m4/check-iso-c99.m4 b/m4/check-iso-c99.m4 new file mode 100644 index 0000000000000000000000000000000000000000..142c3fb8861e7fade3a91fbfd28a1e6f0e739c91 --- /dev/null +++ b/m4/check-iso-c99.m4 @@ -0,0 +1,30 @@ +# +# We need (at least) two features from the C99 standard: variadic +# macros and variable length arrays. We check here whether or those +# are available. +# +# Note that we do not further modify the compiler flags, we just check +# whether variadic macros and variable length arrays are available. +# +# The macro takes 2 arguments: +# +# $1: optional: a set of compiler flags in addition to CFLAGS +# +AC_DEFUN([ALBERTA_ISO_C99_CHECK], +[AC_REQUIRE([AC_PROG_CC]) +_alberta_save_cflags="${CFLAGS}" +m4_if($#,1,[CFLAGS="$1"]) +AC_LANG_PUSH([C]) +AC_MSG_CHECKING([for ISO C99 features with "${CC} ${CFLAGS}"]) +AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( +[[extern void exit(int status); +#define FOO(a, ...) (a, __VA_ARGS__) +extern int foo(int a, int b, int c);]], +[[int bar[foo FOO(3, 4, 5)]; +exit(bar[0]);]])], +[AC_MSG_RESULT([variadic macros and variable length arrays available])], +[AC_MSG_FAILURE([variadic macros and/or vairable length arrays NOT available])]) +AC_LANG_POP([C]) +CFLAGS="${_alberta_save_cflags}" +])