diff --git a/m4/virt-compile-warnings.m4 b/m4/virt-compile-warnings.m4 index 532a7777e8..8aebdb0541 100644 --- a/m4/virt-compile-warnings.m4 +++ b/m4/virt-compile-warnings.m4 @@ -215,6 +215,12 @@ AC_DEFUN([LIBVIRT_COMPILE_WARNINGS],[ ;; esac + case $WARN_CFLAGS in + *-Wsuggest-attribute=format*) + AC_DEFINE([HAVE_SUGGEST_ATTRIBUTE_FORMAT], [1], [Whether -Wsuggest-attribute=format works]) + ;; + esac + # Silence certain warnings in gnulib, and use improved glibc headers AC_DEFINE([lint], [1], [Define to 1 if the compiler is checking for lint.]) diff --git a/src/internal.h b/src/internal.h index 9855c49912..4d473afdf9 100644 --- a/src/internal.h +++ b/src/internal.h @@ -234,9 +234,15 @@ # define VIR_WARNINGS_NO_CAST_ALIGN \ _Pragma ("GCC diagnostic push") \ _Pragma ("GCC diagnostic ignored \"-Wcast-align\"") -# define VIR_WARNINGS_NO_PRINTF \ + +# if HAVE_SUGGEST_ATTRIBUTE_FORMAT +# define VIR_WARNINGS_NO_PRINTF \ _Pragma ("GCC diagnostic push") \ _Pragma ("GCC diagnostic ignored \"-Wsuggest-attribute=format\"") +# else +# define VIR_WARNINGS_NO_PRINTF \ + _Pragma ("GCC diagnostic push") +# endif # define VIR_WARNINGS_RESET \ _Pragma ("GCC diagnostic pop")