[glib] win32: avoid printf format warnings on nonstandard formats



commit fc3acd88baad368b70f6b263e74c945e15fdc8ef
Author: Dan Winship <danw gnome org>
Date:   Sun Nov 11 11:29:16 2012 -0500

    win32: avoid printf format warnings on nonstandard formats
    
    glib/tests/test-printf tests some non-standard printf formats on
    Windows, which gcc doesn't recognize, and so complains about. Disable
    those warnings for that test.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=688109

 glib/tests/test-printf.c |   28 ++++++++++++++++++++++++++++
 1 files changed, 28 insertions(+), 0 deletions(-)
---
diff --git a/glib/tests/test-printf.c b/glib/tests/test-printf.c
index 7f48b9e..10d0a1d 100644
--- a/glib/tests/test-printf.c
+++ b/glib/tests/test-printf.c
@@ -721,6 +721,15 @@ test_64bit (void)
    * GLib 2.2, so it's best if it continues to work.
    */
 
+  /* However, gcc doesn't know about this, so we need to disable printf
+   * format warnings...
+   */
+#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
+_Pragma ("GCC diagnostic push")
+_Pragma ("GCC diagnostic ignored \"-Wformat\"")
+_Pragma ("GCC diagnostic ignored \"-Wformat-extra-args\"")
+#endif
+
   res = g_snprintf (buf, 128, "%" "lli", (gint64)123456);
   g_assert_cmpint (res, ==, 6);
   g_assert_cmpstr (buf, ==, "123456");
@@ -752,6 +761,11 @@ test_64bit (void)
   res = g_snprintf (buf, 128, "%" "ll" "X", (gint64)123456);
   g_assert_cmpint (res, ==, 5);
   g_assert_cmpstr (buf, ==, "1E240");
+
+#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
+_Pragma ("GCC diagnostic pop")
+#endif
+
 #endif
 }
 
@@ -840,6 +854,15 @@ test_64bit2 (void)
    * GLib 2.2, so it's best if it continues to work.
    */
 
+  /* However, gcc doesn't know about this, so we need to disable printf
+   * format warnings...
+   */
+#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
+_Pragma ("GCC diagnostic push")
+_Pragma ("GCC diagnostic ignored \"-Wformat\"")
+_Pragma ("GCC diagnostic ignored \"-Wformat-extra-args\"")
+#endif
+
   if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDOUT))
     {
       res = g_printf ("%" "lli", (gint64)123456);
@@ -911,6 +934,11 @@ test_64bit2 (void)
     }
   g_test_trap_assert_passed ();
   g_test_trap_assert_stdout ("*1E240*");
+
+#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
+_Pragma ("GCC diagnostic pop")
+#endif
+
 #endif
 }
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]