]> eyrie.org Git - kerberos/krb5-strength.git/blob - m4/vamacros.m4
Declare fast forward from 3.1-2
[kerberos/krb5-strength.git] / m4 / vamacros.m4
1 dnl Check for support for variadic macros.
2 dnl
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:
6 dnl
7 dnl     #define macro(...) fprintf(stderr, __VA_ARGS__)
8 dnl
9 dnl and RRA_C_GNU_VAMACROS, which checks for support for the older GNU
10 dnl variadic macro syntax, namely:
11 dnl
12 dnl    #define macro(args...) fprintf(stderr, args)
13 dnl
14 dnl They set HAVE_C99_VAMACROS or HAVE_GNU_VAMACROS as appropriate.
15 dnl
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/>.
18 dnl
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
22 dnl
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.
26 dnl
27 dnl SPDX-License-Identifier: FSFULLR
28
29 AC_DEFUN([_RRA_C_C99_VAMACROS_SOURCE], [[
30 #include <stdio.h>
31 #define error(...) fprintf(stderr, __VA_ARGS__)
32
33 int
34 main(void) {
35     error("foo");
36     error("foo %d", 0);
37     return 0;
38 }
39 ]])
40
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.])])])
49
50 AC_DEFUN([_RRA_C_GNU_VAMACROS_SOURCE], [[
51 #include <stdio.h>
52 #define error(args...) fprintf(stderr, args)
53
54 int
55 main(void) {
56     error("foo");
57     error("foo %d", 0);
58     return 0;
59 }
60 ]])
61
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.])])])