GNOME Bugzilla – Bug 791532
Implicit declaration of function ‘memcmp’ in gtestutils.h
Last modified: 2017-12-13 16:03:46 UTC
Created attachment 365451 [details] bug.c The 'g_assert_cmpmem()' macro defined in the 'glib/gtestutils.h' header, uses the 'memcmp()' function of the stdlib without including the 'string.h' header. Thus, the attached test program (bug.c), does not compile when the '-Werror' option is enabled. As shown by the following compiler error messages: $ gcc -Werror -I/usr/include/glib-2.0 -I/usr/lib/i386-linux-gnu/glib-2.0/include -lglib-2.0 bug.c In file included from /usr/include/glib-2.0/glib.h:82:0, from bug.c:1: bug.c: In function ‘main’: /usr/include/glib-2.0/glib/gtestutils.h:77:55: error: implicit declaration of function ‘memcmp’ [-Werror=implicit-function-declaration] else if (memcmp (__m1, __m2, __l1) != 0) \ ^ bug.c:8:5: note: in expansion of macro ‘g_assert_cmpmem’ g_assert_cmpmem(foo, sizeof(foo), bar, sizeof(bar)); ^ cc1: all warnings being treated as errors I know, this might be a really easy bug fix. I am new to glib and I am not sure if it is okay just to add the '#include <string.h>' statement to the 'glib/gtestutils.h' header or if there is some more abstraction needed like a 'g_memcmp()' function or what ever? Cheers, Stefan
Created attachment 365487 [details] [review] gtestutils: Add missing include memcmp() is used, which is declared in string.h. Include that. Signed-off-by: Philip Withnall <withnall@endlessm.com>
Review of attachment 365487 [details] [review]: :thumbsup:
Thanks for the fast patch review. Attachment 365487 [details] pushed as 6a597f9 - gtestutils: Add missing include
Review of attachment 365487 [details] [review]: That was fast and exactly what I would have done as well. Thank you.