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 dnl SPDX-License-Identifier: FSFULLR
29 AC_DEFUN([_RRA_C_C99_VAMACROS_SOURCE], [[
31 #define error(...) fprintf(stderr, __VA_ARGS__)
41 AC_DEFUN([RRA_C_C99_VAMACROS],
42 [AC_CACHE_CHECK([for C99 variadic macros], [rra_cv_c_c99_vamacros],
43 [AC_COMPILE_IFELSE([AC_LANG_SOURCE([_RRA_C_C99_VAMACROS_SOURCE])],
44 [rra_cv_c_c99_vamacros=yes],
45 [rra_cv_c_c99_vamacros=no])])
46 AS_IF([test x"$rra_cv_c_c99_vamacros" = xyes],
47 [AC_DEFINE([HAVE_C99_VAMACROS], 1,
48 [Define if the compiler supports C99 variadic macros.])])])
50 AC_DEFUN([_RRA_C_GNU_VAMACROS_SOURCE], [[
52 #define error(args...) fprintf(stderr, args)
62 AC_DEFUN([RRA_C_GNU_VAMACROS],
63 [AC_CACHE_CHECK([for GNU-style variadic macros], [rra_cv_c_gnu_vamacros],
64 [AC_COMPILE_IFELSE([AC_LANG_SOURCE([_RRA_C_GNU_VAMACROS_SOURCE])],
65 [rra_cv_c_gnu_vamacros=yes],
66 [rra_cv_c_gnu_vamacros=no])])
67 AS_IF([test x"$rra_cv_c_gnu_vamacros" = xyes],
68 [AC_DEFINE([HAVE_GNU_VAMACROS], 1,
69 [Define if the compiler supports GNU-style variadic macros.])])])