From: Todd C. Miller Date: Thu, 1 Mar 2012 18:05:03 +0000 (-0500) Subject: Add check for variadic macro support in cpp. X-Git-Tag: SUDO_1_8_5~1^2~180 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=06e390a5660bf99926616371148b39a2e8a10660;p=sudo Add check for variadic macro support in cpp. --- diff --git a/configure b/configure index eaee4872d..18f745fc1 100755 --- a/configure +++ b/configure @@ -14584,6 +14584,31 @@ $as_echo "#define volatile /**/" >>confdefs.h fi +# Check for variadic macro support in cpp +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +$ac_includes_default +#if defined(__GNUC__) && __GNUC__ == 2 +# define sudo_fprintf(fp, fmt...) fprintf((fp), (fmt)) +#else +# define sudo_fprintf(fp, ...) fprintf((fp), __VA_ARGS__) +#endif + +int +main () +{ +sudo_fprintf(stderr, "a %s", "test"); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + +else + as_fn_error $? "Your C compiler doesn't support variadic macros, try building with gcc instead" "$LINENO" 5 +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test X"$with_gnu_ld" != "yes" -a -n "$GCC"; then _CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -static-libgcc" diff --git a/configure.in b/configure.in index 833bf7895..90be2da5c 100644 --- a/configure.in +++ b/configure.in @@ -1953,6 +1953,15 @@ dnl AC_PROG_GCC_TRADITIONAL AC_C_CONST AC_C_VOLATILE +# Check for variadic macro support in cpp +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([ +AC_INCLUDES_DEFAULT +#if defined(__GNUC__) && __GNUC__ == 2 +# define sudo_fprintf(fp, fmt...) fprintf((fp), (fmt)) +#else +# define sudo_fprintf(fp, ...) fprintf((fp), __VA_ARGS__) +#endif +], [sudo_fprintf(stderr, "a %s", "test");])], [], [AC_MSG_ERROR([Your C compiler doesn't support variadic macros, try building with gcc instead])]) if test X"$with_gnu_ld" != "yes" -a -n "$GCC"; then _CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -static-libgcc"