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