autoupdate
[gnulib.git] / m4 / va-args.m4
blob63c553589e98e237912ec20e50f2470b70981f51
1 # va-args.m4
2 # serial 1
3 dnl Copyright (C) 2009-2024 Free Software Foundation, Inc.
4 dnl This file is free software; the Free Software Foundation
5 dnl gives unlimited permission to copy and/or distribute it,
6 dnl with or without modifications, as long as this notice is preserved.
7 dnl This file is offered as-is, without any warranty.
9 dnl Test for variadic macro support.
10 dnl Define HAVE_VA_ARGS if macros can use __VA_ARGS__.
11 AC_DEFUN([gl_VA_ARGS],
13   AC_CACHE_CHECK([whether the preprocessor allows variadic macros],
14     [gl_cv_c_va_args],
15     [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
16        #include <stdio.h>
17        #define a(func, arg, ...) func (arg, __VA_ARGS__)
18        #define b(...) a (__VA_ARGS__)
19       ]], [[b (printf, "%s", "test");]])],
20       [gl_cv_c_va_args=yes], [gl_cv_c_va_args=no])
21     ])
22   if test $gl_cv_c_va_args = yes; then
23     AC_DEFINE([HAVE_VA_ARGS], [1],
24       [Define to 1 if the preprocessor supports variadic macros and
25        __VA_ARGS__.])
26   fi