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.

66 lines
1.4 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. ]],
  17. [[
  18. using namespace std;
  19. #define MACRO(buf, ...) (sprintf (buf, "%d", __VA_ARGS__))
  20. char a[10];
  21. MACRO(a, 1);
  22. if (a[0] != '1')
  23. abort ();
  24. if (a[1] != 0)
  25. abort ();
  26. ]]
  27. )],
  28. [ac_cv_c99_variadic_macros=yes],
  29. [ac_cv_c99_variadic_macros=no])
  30. ])
  31. ])
  32. AC_DEFUN([AX_GNU_VARIADIC_MACROS],
  33. [
  34. AH_TEMPLATE([HAS_GNU_VARIADIC_MACROS],
  35. [Defined if the compiler supports GNU style variadic macros.])
  36. AC_CACHE_CHECK([for GNU style variadic macros], [ac_cv_gnu_variadic_macros],
  37. [
  38. AC_LANG_ASSERT([C++])
  39. AC_COMPILE_IFELSE(
  40. [AC_LANG_PROGRAM(
  41. [[
  42. #include <cstdio>
  43. #include <cstdlib>
  44. ]],
  45. [[
  46. using namespace std;
  47. #define MACRO(buf, args...) (sprintf (buf, "%d", args))
  48. char a[10];
  49. MACRO(a, 1);
  50. if (a[0] != '1')
  51. abort ();
  52. if (a[1] != 0)
  53. abort ();
  54. ]]
  55. )],
  56. [ac_cv_gnu_variadic_macros=yes],
  57. [ac_cv_gnu_variadic_macros=no])
  58. ])
  59. ])