You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

68 lines
1.5 KiB

  1. dnl Two functions for checking for availability of C99 style
  2. dnl __VA_ARGS__ and GNU style args... variadic macro support.
  3. AC_DEFUN([AX_C99_VARIADIC_MACROS],
  4. [
  5. AH_TEMPLATE([HAS_C99_VARIADIC_MACROS],
  6. [Defined if the compiler supports C99 style variadic macros with
  7. __VA_ARGS__.])
  8. AC_CACHE_CHECK([for C99 variadic macros], [ac_cv_c99_variadic_macros],
  9. [
  10. AC_LANG_ASSERT([C++])
  11. AC_COMPILE_IFELSE(
  12. [AC_LANG_PROGRAM(
  13. [[
  14. #include <cstdio>
  15. #include <cstdlib>
  16. #include <cstddef>
  17. ]],
  18. [[
  19. using namespace std;
  20. #define MACRO(buf, ...) (sprintf (buf, "%d", __VA_ARGS__))
  21. char a[10];
  22. MACRO(a, 1);
  23. if (a[0] != '1')
  24. abort ();
  25. if (a[1] != 0)
  26. abort ();
  27. ]]
  28. )],
  29. [ac_cv_c99_variadic_macros=yes],
  30. [ac_cv_c99_variadic_macros=no])
  31. ])
  32. ])
  33. AC_DEFUN([AX_GNU_VARIADIC_MACROS],
  34. [
  35. AH_TEMPLATE([HAS_GNU_VARIADIC_MACROS],
  36. [Defined if the compiler supports GNU style variadic macros.])
  37. AC_CACHE_CHECK([for GNU style variadic macros], [ac_cv_gnu_variadic_macros],
  38. [
  39. AC_LANG_ASSERT([C++])
  40. AC_COMPILE_IFELSE(
  41. [AC_LANG_PROGRAM(
  42. [[
  43. #include <cstdio>
  44. #include <cstdlib>
  45. #include <cstddef>
  46. ]],
  47. [[
  48. using namespace std;
  49. #define MACRO(buf, args...) (sprintf (buf, "%d", args))
  50. char a[10];
  51. MACRO(a, 1);
  52. if (a[0] != '1')
  53. abort ();
  54. if (a[1] != 0)
  55. abort ();
  56. ]]
  57. )],
  58. [ac_cv_gnu_variadic_macros=yes],
  59. [ac_cv_gnu_variadic_macros=no])
  60. ])
  61. ])