]> xenbits.xensource.com Git - libvirt.git/commitdiff
Conditionalize use of -Wno-suggest-attribute=format pragma
authorDaniel P. Berrange <berrange@redhat.com>
Fri, 16 Jan 2015 14:45:08 +0000 (14:45 +0000)
committerDaniel P. Berrange <berrange@redhat.com>
Fri, 16 Jan 2015 17:12:27 +0000 (17:12 +0000)
Many GCC versions don't understand -Wno-suggest-attribute=format
so the pragma must only be used when supported

m4/virt-compile-warnings.m4
src/internal.h

index 532a7777e8d6e1ac08adb5144a309a1266b8c4ca..8aebdb05419437389b94a7de4a96e1555cadb0a4 100644 (file)
@@ -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.])
index 9855c499127ea78d70059c04dbc0c8a540d1526f..4d473afdf98fb84bec22a8b32ada7e8f2d7c9ce0 100644 (file)
 #  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")