diff options
Diffstat (limited to 'config/c-compiler.m4')
-rw-r--r-- | config/c-compiler.m4 | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/config/c-compiler.m4 b/config/c-compiler.m4 index 2cf74bbb2ae..90b56e770c9 100644 --- a/config/c-compiler.m4 +++ b/config/c-compiler.m4 @@ -51,6 +51,27 @@ fi ])# PGAC_C_INLINE +# PGAC_C_PRINTF_ARCHETYPE +# ----------------------- +# Set the format archetype used by gcc to check printf type functions. We +# prefer "gnu_printf", which includes what glibc uses, such as %m for error +# strings and %lld for 64 bit long longs. GCC 4.4 introduced it. It makes a +# dramatic difference on Windows. +AC_DEFUN([PGAC_PRINTF_ARCHETYPE], +[AC_CACHE_CHECK([for printf format archetype], pgac_cv_printf_archetype, +[ac_save_c_werror_flag=$ac_c_werror_flag +ac_c_werror_flag=yes +AC_COMPILE_IFELSE([AC_LANG_PROGRAM( +[extern int +pgac_write(int ignore, const char *fmt,...) +__attribute__((format(gnu_printf, 2, 3)));], [])], + [pgac_cv_printf_archetype=gnu_printf], + [pgac_cv_printf_archetype=printf]) +ac_c_werror_flag=$ac_save_c_werror_flag]) +AC_DEFINE_UNQUOTED([PG_PRINTF_ATTRIBUTE], [$pgac_cv_printf_archetype], + [Define to gnu_printf if compiler supports it, else printf.]) +])# PGAC_PRINTF_ARCHETYPE + # PGAC_TYPE_64BIT_INT(TYPE) # ------------------------- |