目录
编译openwrt sdk时,出现个gdate.c的错误,与编译器版本有关,打个patch就好
编译openwrt问题:
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'
解决:
单独改源码方式不好,下次重新编译有可能又要重新改, 所以新建个patch一劳永逸
在tools/pkg-config/patches/目录下创建新文件001-glib-gdate-suppress-string-format-literal-warning.patch
内容如下:
--- 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
创建完,再执行编译,编译过程openwrt会自动把这个patch打到源码中,无需手动执行patch。