1 dnl Check for support for variadic macros.
3 dnl This file defines two macros for probing for compiler support for variadic
4 dnl macros. Provided are RRA_C_C99_VAMACROS, which checks for support for the
5 dnl C99 variadic macro syntax, namely:
7 dnl #define macro(...) fprintf(stderr, __VA_ARGS__)
9 dnl and RRA_C_GNU_VAMACROS, which checks for support for the older GNU
10 dnl variadic macro syntax, namely:
12 dnl #define macro(args...) fprintf(stderr, args)
14 dnl They set HAVE_C99_VAMACROS or HAVE_GNU_VAMACROS as appropriate.
16 dnl The canonical version of this file is maintained in the rra-c-util
17 dnl package, available at <https://www.eyrie.org/~eagle/software/rra-c-util/>.
19 dnl Written by Russ Allbery <eagle@eyrie.org>
20 dnl Copyright 2006, 2008, 2009
21 dnl The Board of Trustees of the Leland Stanford Junior University
23 dnl This file is free software; the authors give unlimited permission to copy
24 dnl and/or distribute it, with or without modifications, as long as this
25 dnl notice is preserved.
27 AC_DEFUN([_RRA_C_C99_VAMACROS_SOURCE], [[
29 #define error(...) fprintf(stderr, __VA_ARGS__)
39 AC_DEFUN([RRA_C_C99_VAMACROS],
40 [AC_CACHE_CHECK([for C99 variadic macros], [rra_cv_c_c99_vamacros],
41 [AC_COMPILE_IFELSE([AC_LANG_SOURCE([_RRA_C_C99_VAMACROS_SOURCE])],
42 [rra_cv_c_c99_vamacros=yes],
43 [rra_cv_c_c99_vamacros=no])])
44 AS_IF([test x"$rra_cv_c_c99_vamacros" = xyes],
45 [AC_DEFINE([HAVE_C99_VAMACROS], 1,
46 [Define if the compiler supports C99 variadic macros.])])])
48 AC_DEFUN([_RRA_C_GNU_VAMACROS_SOURCE], [[
50 #define error(args...) fprintf(stderr, args)
60 AC_DEFUN([RRA_C_GNU_VAMACROS],
61 [AC_CACHE_CHECK([for GNU-style variadic macros], [rra_cv_c_gnu_vamacros],
62 [AC_COMPILE_IFELSE([AC_LANG_SOURCE([_RRA_C_GNU_VAMACROS_SOURCE])],
63 [rra_cv_c_gnu_vamacros=yes],
64 [rra_cv_c_gnu_vamacros=no])])
65 AS_IF([test x"$rra_cv_c_gnu_vamacros" = xyes],
66 [AC_DEFINE([HAVE_GNU_VAMACROS], 1,
67 [Define if the compiler supports GNU-style variadic macros.])])])