This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: MinGW compilation warnings in libiberty's xstrndup.c
- From: Pedro Alves <palves at redhat dot com>
- To: Eli Zaretskii <eliz at gnu dot org>
- Cc: gcc-patches at gcc dot gnu dot org, gdb-patches at sourceware dot org, thomas at codesourcery dot com
- Date: Fri, 19 May 2017 17:07:05 +0100
- Subject: Re: MinGW compilation warnings in libiberty's xstrndup.c
- Authentication-results: sourceware.org; auth=none
- References: <83h90vcqo6.fsf@gnu.org> <60a354b0-6c1a-15ea-177a-8bdb198c8c03@redhat.com> <83a8683ler.fsf@gnu.org>
On 05/19/2017 04:40 PM, Eli Zaretskii wrote:
>> Cc: gdb-patches@sourceware.org, Thomas Schwinge <thomas@codesourcery.com>
>> From: Pedro Alves <palves@redhat.com>
>> Date: Fri, 19 May 2017 16:22:55 +0100
>>
>> But then, xstrndup.c has at the top:
>>
>> #ifdef HAVE_STRING_H
>> #include <string.h>
>> #else
>> # ifdef HAVE_STRINGS_H
>> # include <strings.h>
>> # endif
>> #endif
>>
>> So I would expect your build to pick the strnlen declaration from
>> one of the string.h or strings.h mingw headers. Why didn't it?
>
> Because MinGW doesn't have it, not unless you build a program that
> will require one of the newer versions of the Windows C runtime
> library. That's why libiberty's strnlen is being compiled in the
> MinGW build in the first place.
OK, I didn't realize there was a strnlen replacement too.
>
> Specifically, the MinGW headers do provide a prototype for strnlen if
> the program defines __MSVCRT_VERSION__ to be a high enough version, or
> defines _POSIX_C_SOURCE >= 200809L, but none of these is set by
> default, and is not a good idea, as explained above, for a program
> that needs to run on a wide variety of OS versions.
>
> IOW, libiberty shouldn't rely on the system headers to provide a
> strnlen prototype when libiberty's strnlen is being included in the
> library as a replacement.
OK, I guess then we're up to figuring out which direction to go.
Either an AC_CHECK_DECL is missing on libiberty's configure,
or the original patch really wanted AC_CHECK_FUNC instead of
AC_CHECK_DECL. Or something else, I only look at libiberty's
configury every couple of years and forget how this is all
supposed to work in between.
Thanks,
Pedro Alves