gdate.c:2497:7: error: format not a string literal, format string not checked [-Werror=format-nonlit

Copyright: original articles without consent, is prohibited reprint https://blog.csdn.net/zmlovelx/article/details/81664043

Compile class openwrt when sdk, a gdate.c error occurs, the version of the compiler, make a patch like

problem:

gdate.c: In function 'g_date_strftime':
gdate.c:2497:7: error: format not a string literal, format string not checked [-Werror=format-nonliteral]
      tmplen = strftime (tmpbuf, tmpbufsize, locale_format, &tm);
      ^~~~~~
cc1: some warnings being treated as errors
make[10]: *** [Makefile:1386: libglib_2_0_la-gdate.lo] Error 1
make[10]: Leaving directory '/opt/water/tina-sdk/out/mandolin-perf1/compile_dir/host/pkg-config-0.29/glib/glib'
 

solve:

Not a single way to change the source code, recompile the next time there may have to change again, so a new patch once and for all

tools/pkg-config/patches/001-glib-gdate-suppress-string-format-literal-warning.patch

It reads as follows:

--- a/glib/glib/gdate.c
+++ b/glib/glib/gdate.c
@@ -2439,6 +2439,9 @@ win32_strftime_helper (const GDate     *d,
  *
  * Returns: number of characters written to the buffer, or 0 the buffer was too small
  */
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wformat-nonliteral"
+
 gsize     
 g_date_strftime (gchar       *s, 
                  gsize        slen, 
@@ -2549,3 +2552,5 @@ g_date_strftime (gchar       *s,
   return retval;
 #endif
 }
+
+#pragma GCC diagnostic pop

 

Guess you like

Origin blog.csdn.net/zmlovelx/article/details/81664043