diff options
author | Noah Misch | 2014-11-23 14:34:03 +0000 |
---|---|---|
committer | Noah Misch | 2014-11-23 14:34:03 +0000 |
commit | b779168ffe330d137b8b4329a7710c8bf1f7e661 (patch) | |
tree | 37c491a99621f59e83bd9fc6c4a13190ae2575ff /config/c-compiler.m4 | |
parent | b62f94c60386796fd88256c5b7b1e8301c345166 (diff) |
Detect PG_PRINTF_ATTRIBUTE automatically.
This eliminates gobs of "unrecognized format function type" warnings
under MinGW compilers predating GCC 4.4.
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 2cf74bbb2a..90b56e770c 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) # ------------------------- |