1#
2# We need (at least) two features from the C99 standard: variadic
3# macros and variable length arrays. We check here whether or those
4# are available.
5#
6# Note that we do not further modify the compiler flags, we just check
7# whether variadic macros and variable length arrays are available.
8#
9# The macro takes 2 arguments:
10#
11# $1: optional: a set of compiler flags in addition to CFLAGS
12#
13AC_DEFUN([ALBERTA_ISO_C99_CHECK],
14[AC_REQUIRE([AC_PROG_CC])
15_alberta_save_cflags="${CFLAGS}"
16m4_if($#,1,[CFLAGS="$1"])
17AC_LANG_PUSH([C])
18AC_MSG_CHECKING([for ISO C99 features with "${CC} ${CFLAGS}"])
19AC_COMPILE_IFELSE(
20	[AC_LANG_PROGRAM(
21[[extern void exit(int status);
22#define FOO(a, ...)  (a, __VA_ARGS__)
23#include <stdarg.h>
24#include <string.h>
25void va_copy_test(va_list ap)
26{
27  va_list ap2;
28  va_copy(ap2, ap);
29  va_end(ap2);
30}
31int funclen(void)
32{
33  return (int)strlen(__func__);
34}
35extern int foo(int a, int b, int c);]],
36[[int bar[foo FOO(3, 4, 5)];
37exit(bar[0]);]])],
38[AC_MSG_RESULT(
39  [variadic macros, va_copy(), __func__ and variable length arrays are available])],
40[AC_MSG_FAILURE(
41 [variadic macros, va_copy(), __func__ and/or vairable length arrays are NOT available])])
42AC_LANG_POP([C])
43CFLAGS="${_alberta_save_cflags}"
44])
45