[libepc] Avoid (via #pragma) gcc format-y2k warning.



commit feb8dd244727c674a2a51f8855ac372c0a2b4261
Author: Murray Cumming <murrayc murrayc com>
Date:   Mon Jun 19 21:02:25 2017 +0200

    Avoid (via #pragma) gcc format-y2k warning.

 examples/simple-publisher.c |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)
---
diff --git a/examples/simple-publisher.c b/examples/simple-publisher.c
index 2ea566d..0192bd3 100644
--- a/examples/simple-publisher.c
+++ b/examples/simple-publisher.c
@@ -34,7 +34,14 @@ timestamp_handler_date (EpcPublisher *publisher G_GNUC_UNUSED,
   /* Create custom content */
 
   buffer = g_malloc (length);
+
+  // Ignore the gcc warning:
+  // error: ‘%x’ yields only last 2 digits of year in some locales [-Werror=format-y2k]
+  // because there doesn't seem to be any way to show 4 digits in the correct format for the locale.
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wformat-y2k"
   length = strftime (buffer, length, "%x", tm);
+#pragma GCC diagnostic pop
 
   return epc_contents_new ("text/plain", buffer, length, g_free);
 }
@@ -70,7 +77,14 @@ timestamp_handler_date_time (EpcPublisher *publisher G_GNUC_UNUSED,
   /* Create custom content */
 
   buffer = g_malloc (length);
+
+  // Ignore the gcc warning:
+  // error: ‘%x’ yields only last 2 digits of year in some locales [-Werror=format-y2k]
+  // because there doesn't seem to be any way to show 4 digits in the correct format for the locale.
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wformat-y2k"
   length = strftime (buffer, length, "%x %X", tm);
+#pragma GCC diagnostic pop
 
   return epc_contents_new ("text/plain", buffer, length, g_free);
 }


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