This is the mail archive of the
gdb@sourceware.org
mailing list for the GDB project.
Re: [RFC] BFD MinGW/Cygwin build error in bfd/peiXXgen.c
- From: asmwarrior <asmwarrior at gmail dot com>
- To: Pierre Muller <pierre dot muller at ics-cnrs dot unistra dot fr>, 'Pedro Alves' <palves at redhat dot com>
- Cc: 'GDB Development' <gdb at sourceware dot org>, 'Binutils Development' <binutils at sourceware dot org>
- Date: Wed, 18 Dec 2013 21:24:28 +0800
- Subject: Re: [RFC] BFD MinGW/Cygwin build error in bfd/peiXXgen.c
- Authentication-results: sourceware.org; auth=none
- References: <52B17083 dot 7040404 at gmail dot com> <52B1738D dot 4010409 at redhat dot com> <52b19d01 dot 22cbc20a dot 69b0 dot ffffb29eSMTPIN_ADDED_BROKEN at mx dot google dot com>
On 2013-12-18 21:02, Pierre Muller wrote:
> Cygwin also fails to compile bfd/peigen.c, itself gebnerated
> from source bfd/peXXigen.c.
>
> The patch below allows to compile both for mingw32 and cygwin hosts.
> To fix the unknown wcsncasecmp function for mingw32 hosts,
> I added this code:
>
> +#ifdef __MINGW32__
> +#define wcsncasecmp wcsnicmp
> +#endif
> I think that using the Windows API function wcsnicmp
> here is OK, but I don't know if the code should be somehow modified to
> accept wcsncasecmp function if it is added later to mingw hosts...
>
> Pierre Muller
>
>
> bfd/ChangeLog entry:
>
> 2013-12-18 Pierre Muller <muller@sourceware.org>
>
> peXXigen.c (u16_mbtouc): Avoid unused function warning by exculding if
> __CYGWIN__ or __MINGW32__ macro is defined.
> (rsrc_cmp): Fix short Windows OS version. Also use this code
> for mingw32 systems.
> [__MINGW32__]: Alias wcsncasecmp function to Windows API wcsnicmp function.
>
> diff --git a/bfd/peXXigen.c b/bfd/peXXigen.c
> index 5e2a876..05c7d8b 100644
> --- a/bfd/peXXigen.c
> +++ b/bfd/peXXigen.c
> @@ -2930,7 +2930,7 @@ rsrc_write_directory (rsrc_write_data * data,
> BFD_ASSERT (nt == next_entry);
> }
>
> -#ifdef HAVE_WCHAR_H
> +#if defined HAVE_WCHAR_H && ! defined __CYGWIN__ && ! defined __MINGW32__
> /* Return the length (number of units) of the first character in S,
> putting its 'ucs4_t' representation in *PUC. */
>
> @@ -2979,9 +2979,16 @@ rsrc_cmp (bfd_boolean is_name, rsrc_entry * a, rsrc_entry * b)
> /* We have to perform a case insenstive, unicode string comparison... */
> int res;
>
> -#ifdef __CYGWIN__
> +#if defined __CYGWIN__ || defined __MINGW32__
> +#ifdef __MINGW32__
> +#define wcsncasecmp wcsnicmp
> +#endif
> /* Under Cygwin unicode == UTF-16 == wchar_t.
> FIXME: The same is true for MingGW - we should test for that too. */
> + bfd_byte * astring = a->name_id.name.string;
> + unsigned int alen = a->name_id.name.len;
> + bfd_byte * bstring = b->name_id.name.string;
> + unsigned int blen = b->name_id.name.len;
> res = wcsncasecmp ((const wchar_t *) astring + 2, (const wchar_t *) bstring + 2, min (alen, blen));
> #elif defined HAVE_WCHAR_H
> unsigned int i;
Thanks, just test this patch, it fix the build error under MinGW-Build 4.8.2 + MSYS.
Yuanhui Zhang