]> eyrie.org Git - kerberos/krb5-strength.git/blob - m4/vamacros.m4
Change CrackLib tests for system CrackLib
[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
27 AC_DEFUN([_RRA_C_C99_VAMACROS_SOURCE], [[
28 #include <stdio.h>
29 #define error(...) fprintf(stderr, __VA_ARGS__)
30
31 int
32 main(void) {
33     error("foo");
34     error("foo %d", 0);
35     return 0;
36 }
37 ]])
38
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.])])])
47
48 AC_DEFUN([_RRA_C_GNU_VAMACROS_SOURCE], [[
49 #include <stdio.h>
50 #define error(args...) fprintf(stderr, args)
51
52 int
53 main(void) {
54     error("foo");
55     error("foo %d", 0);
56     return 0;
57 }
58 ]])
59
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.])])])