This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
MinGW compilation warnings in libiberty's xstrndup.c
- From: Eli Zaretskii <eliz at gnu dot org>
- To: gcc-patches at gcc dot gnu dot org
- Cc: gdb-patches at sourceware dot org
- Date: Mon, 08 May 2017 18:30:01 +0300
- Subject: MinGW compilation warnings in libiberty's xstrndup.c
- Authentication-results: sourceware.org; auth=none
- Reply-to: Eli Zaretskii <eliz at gnu dot org>
When compiling libiberty (as part of GDB) with MinGW on MS-Windows, I
see the following warning:
gcc -c -DHAVE_CONFIG_H -O2 -gdwarf-4 -g3 -D__USE_MINGW_ACCESS -I. -I./../include -W -Wall -Wwrite-strings -Wc++-compat -Wstrict-prototypes -pedantic -D_GNU_SOURCE ./xstrndup.c -o xstrndup.o
./xstrndup.c: In function 'xstrndup':
./xstrndup.c:51:16: warning: implicit declaration of function 'strnlen' [-Wimplicit-function-declaration]
size_t len = strnlen (s, n);
^
This happens because libiberty.h uses incorrect guards for the
prototype of strnlen:
#if defined (HAVE_DECL_STRNLEN) && !HAVE_DECL_STRNLEN
extern size_t strnlen (const char *, size_t);
#endif
It should use HAVE_STRNLEN instead, because that's the only
strnlen-related macro defined in config.g when strnlen is probed by
the configure script.
Thanks.