Build error for wcwidth and gcvt

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Build error for wcwidth and gcvt

uchan0+newlib
Hi All,

This is my first mail to newlib community.
I've send this mail because I found some build errors
on newlib's master branch.

Cygwin: unbreak the build with GCC 7
6b7723a83032bd355d3c529d957fe209cb35b4d9

I encountered 2 errors about wcwidth and gcvt.
I've pushed simple patches to forked repository:
https://github.com/uchan-nos/newlib-cygwin/commits/fix-build


Problem 1: Type confliction for wcwith.
wcwidth is declared in newlib/libc/include/wchar.h
as `int wcwidth(const wchar_t);`.
But wcwdth is defined in newlib/libc/string/wcwidth.c
as `int wcwidth(const wint_t wc)`.
These 2 declarations conflicted in my build.

How to fix this problem may not be obvious...
Modifying wint_t --> wchar_t will suppress the build error,
but it may break its functionality for the values which can't
be represented by wchar_t.


Problem 2: Type confliction for gcvt.
gcvt is declared in newlib/libc/include/stdlib.h
if __XSI_VISIBLE >= 4 && __POSIX_VISIBLE < 200112.
gcvt is marked as LEGACY in POSIX.1-2001.

gcvt is defined in newlib/libc/stdlib/efgcvt.c without if-macro
so the function is always compiled.
If you compile newlib with __POSIX_VISIBLE>=200112,
a prototype declaration for gcvt is not supplied.
This causes a build error.
(Implicit declaration of gcvt conflicts with its actual type.)

This problem can be fixed as you surround definitions for
gcvt and other family functions with if-macro:
if __XSI_VISIBLE >= 4 && __POSIX_VISIBLE < 200112.
Reply | Threaded
Open this post in threaded view
|

Re: Build error for wcwidth and gcvt

Corinna Vinschen
On Jul 20 17:50, Kota Uchida wrote:

> Hi All,
>
> This is my first mail to newlib community.
> I've send this mail because I found some build errors
> on newlib's master branch.
>
> Cygwin: unbreak the build with GCC 7
> 6b7723a83032bd355d3c529d957fe209cb35b4d9
>
> I encountered 2 errors about wcwidth and gcvt.
> I've pushed simple patches to forked repository:
> https://github.com/uchan-nos/newlib-cygwin/commits/fix-build
Please send them here in `git format-patch style.


Thanks,
Corinna

--
Corinna Vinschen
Cygwin Maintainer
Red Hat

signature.asc (849 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Build error for wcwidth and gcvt

Thomas Wolff
On 22.07.2019 11:04, Corinna Vinschen wrote:

> On Jul 20 17:50, Kota Uchida wrote:
>> Hi All,
>>
>> This is my first mail to newlib community.
>> I've send this mail because I found some build errors
>> on newlib's master branch.
>>
>> Cygwin: unbreak the build with GCC 7
>> 6b7723a83032bd355d3c529d957fe209cb35b4d9
>>
>> I encountered 2 errors about wcwidth and gcvt.
>> I've pushed simple patches to forked repository:
>> https://github.com/uchan-nos/newlib-cygwin/commits/fix-build
The first patch is not correct:
- wcwidth (const wint_t wc)
+ wcwidth (const wchar_t wc)

Note the manual page.
Even if you see the wchar_t definition for Linux/POSIX, note that
wchar_t has 32 bits there.
On cygwin, however, wchar_t was defined to have only 16 bits,
corresponding to the Windows UTF-16 encoding.
The wcwidth parameter type wint_t is needed to support width enquiries
for non-BMP characters;
changing it would seriously deprive the function of part of its
capabilities.
Thomas

> Please send them here in `git format-patch style.
>
>
> Thanks,
> Corinna
>

Reply | Threaded
Open this post in threaded view
|

Re: Build error for wcwidth and gcvt

Corinna Vinschen
On Jul 22 11:46, Thomas Wolff wrote:

> On 22.07.2019 11:04, Corinna Vinschen wrote:
> > On Jul 20 17:50, Kota Uchida wrote:
> > > Hi All,
> > >
> > > This is my first mail to newlib community.
> > > I've send this mail because I found some build errors
> > > on newlib's master branch.
> > >
> > > Cygwin: unbreak the build with GCC 7
> > > 6b7723a83032bd355d3c529d957fe209cb35b4d9
> > >
> > > I encountered 2 errors about wcwidth and gcvt.
> > > I've pushed simple patches to forked repository:
> > > https://github.com/uchan-nos/newlib-cygwin/commits/fix-build
> The first patch is not correct:
> - wcwidth (const wint_t wc)
> + wcwidth (const wchar_t wc)
>
> Note the manual page.
> Even if you see the wchar_t definition for Linux/POSIX, note that wchar_t
> has 32 bits there.
> On cygwin, however, wchar_t was defined to have only 16 bits, corresponding
> to the Windows UTF-16 encoding.
> The wcwidth parameter type wint_t is needed to support width enquiries for
> non-BMP characters;
> changing it would seriously deprive the function of part of its
> capabilities.
> Thomas
We might need a generic and a Cygwin-specific definition in the source, i.e.

  #ifdef __CYGWIN__
  use wint_t
  #else
  use wchar_t
  #endif

The header should be kept untouched, of course.


Corinna

--
Corinna Vinschen
Cygwin Maintainer
Red Hat

signature.asc (849 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Build error for wcwidth and gcvt

uchan0+newlib
I got understand about wchar_t data sizes.
I fixed my patch and sent it:
https://sourceware.org/ml/newlib/2019/msg00322.html

> The header should be kept untouched, of course.

The header file (wchar.h) must be fixed in order to
match types between the header and .c file.

On Mon, Jul 22, 2019 at 7:51 PM Corinna Vinschen <[hidden email]> wrote:

>
> On Jul 22 11:46, Thomas Wolff wrote:
> > On 22.07.2019 11:04, Corinna Vinschen wrote:
> > > On Jul 20 17:50, Kota Uchida wrote:
> > > > Hi All,
> > > >
> > > > This is my first mail to newlib community.
> > > > I've send this mail because I found some build errors
> > > > on newlib's master branch.
> > > >
> > > > Cygwin: unbreak the build with GCC 7
> > > > 6b7723a83032bd355d3c529d957fe209cb35b4d9
> > > >
> > > > I encountered 2 errors about wcwidth and gcvt.
> > > > I've pushed simple patches to forked repository:
> > > > https://github.com/uchan-nos/newlib-cygwin/commits/fix-build
> > The first patch is not correct:
> > - wcwidth (const wint_t wc)
> > + wcwidth (const wchar_t wc)
> >
> > Note the manual page.
> > Even if you see the wchar_t definition for Linux/POSIX, note that wchar_t
> > has 32 bits there.
> > On cygwin, however, wchar_t was defined to have only 16 bits, corresponding
> > to the Windows UTF-16 encoding.
> > The wcwidth parameter type wint_t is needed to support width enquiries for
> > non-BMP characters;
> > changing it would seriously deprive the function of part of its
> > capabilities.
> > Thomas
>
> We might need a generic and a Cygwin-specific definition in the source, i.e.
>
>   #ifdef __CYGWIN__
>   use wint_t
>   #else
>   use wchar_t
>   #endif
>
> The header should be kept untouched, of course.
>
>
> Corinna
>
> --
> Corinna Vinschen
> Cygwin Maintainer
> Red Hat
Reply | Threaded
Open this post in threaded view
|

Re: Build error for wcwidth and gcvt

Corinna Vinschen
On Jul 23 08:26, Kota Uchida wrote:
> I got understand about wchar_t data sizes.
> I fixed my patch and sent it:
> https://sourceware.org/ml/newlib/2019/msg00322.html
>
> > The header should be kept untouched, of course.
>
> The header file (wchar.h) must be fixed in order to
> match types between the header and .c file.

No, the header needs to stick to wchar_t since that's what the standard
says.  The wint_t for Cygwin is an internal implementation detail.


Corinna


>
> On Mon, Jul 22, 2019 at 7:51 PM Corinna Vinschen <[hidden email]> wrote:
> >
> > On Jul 22 11:46, Thomas Wolff wrote:
> > > On 22.07.2019 11:04, Corinna Vinschen wrote:
> > > > On Jul 20 17:50, Kota Uchida wrote:
> > > > > Hi All,
> > > > >
> > > > > This is my first mail to newlib community.
> > > > > I've send this mail because I found some build errors
> > > > > on newlib's master branch.
> > > > >
> > > > > Cygwin: unbreak the build with GCC 7
> > > > > 6b7723a83032bd355d3c529d957fe209cb35b4d9
> > > > >
> > > > > I encountered 2 errors about wcwidth and gcvt.
> > > > > I've pushed simple patches to forked repository:
> > > > > https://github.com/uchan-nos/newlib-cygwin/commits/fix-build
> > > The first patch is not correct:
> > > - wcwidth (const wint_t wc)
> > > + wcwidth (const wchar_t wc)
> > >
> > > Note the manual page.
> > > Even if you see the wchar_t definition for Linux/POSIX, note that wchar_t
> > > has 32 bits there.
> > > On cygwin, however, wchar_t was defined to have only 16 bits, corresponding
> > > to the Windows UTF-16 encoding.
> > > The wcwidth parameter type wint_t is needed to support width enquiries for
> > > non-BMP characters;
> > > changing it would seriously deprive the function of part of its
> > > capabilities.
> > > Thomas
> >
> > We might need a generic and a Cygwin-specific definition in the source, i.e.
> >
> >   #ifdef __CYGWIN__
> >   use wint_t
> >   #else
> >   use wchar_t
> >   #endif
> >
> > The header should be kept untouched, of course.
> >
> >
> > Corinna
> >
> > --
> > Corinna Vinschen
> > Cygwin Maintainer
> > Red Hat
--
Corinna Vinschen
Cygwin Maintainer
Red Hat

signature.asc (849 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Build error for wcwidth and gcvt

uchan0+newlib
Thank you, Corinna.
I fixed my patch and re-submitted it.
https://sourceware.org/ml/newlib/2019/msg00330.html

I also fixed a patch for compilation error of efgcvt.c
following Yaakov's advice.
https://sourceware.org/ml/newlib/2019/msg00329.html

2019年7月23日(火) 16:56 Corinna Vinschen <[hidden email]>:

>
> On Jul 23 08:26, Kota Uchida wrote:
> > I got understand about wchar_t data sizes.
> > I fixed my patch and sent it:
> > https://sourceware.org/ml/newlib/2019/msg00322.html
> >
> > > The header should be kept untouched, of course.
> >
> > The header file (wchar.h) must be fixed in order to
> > match types between the header and .c file.
>
> No, the header needs to stick to wchar_t since that's what the standard
> says.  The wint_t for Cygwin is an internal implementation detail.
>
>
> Corinna
>
>
> >
> > On Mon, Jul 22, 2019 at 7:51 PM Corinna Vinschen <[hidden email]> wrote:
> > >
> > > On Jul 22 11:46, Thomas Wolff wrote:
> > > > On 22.07.2019 11:04, Corinna Vinschen wrote:
> > > > > On Jul 20 17:50, Kota Uchida wrote:
> > > > > > Hi All,
> > > > > >
> > > > > > This is my first mail to newlib community.
> > > > > > I've send this mail because I found some build errors
> > > > > > on newlib's master branch.
> > > > > >
> > > > > > Cygwin: unbreak the build with GCC 7
> > > > > > 6b7723a83032bd355d3c529d957fe209cb35b4d9
> > > > > >
> > > > > > I encountered 2 errors about wcwidth and gcvt.
> > > > > > I've pushed simple patches to forked repository:
> > > > > > https://github.com/uchan-nos/newlib-cygwin/commits/fix-build
> > > > The first patch is not correct:
> > > > - wcwidth (const wint_t wc)
> > > > + wcwidth (const wchar_t wc)
> > > >
> > > > Note the manual page.
> > > > Even if you see the wchar_t definition for Linux/POSIX, note that wchar_t
> > > > has 32 bits there.
> > > > On cygwin, however, wchar_t was defined to have only 16 bits, corresponding
> > > > to the Windows UTF-16 encoding.
> > > > The wcwidth parameter type wint_t is needed to support width enquiries for
> > > > non-BMP characters;
> > > > changing it would seriously deprive the function of part of its
> > > > capabilities.
> > > > Thomas
> > >
> > > We might need a generic and a Cygwin-specific definition in the source, i.e.
> > >
> > >   #ifdef __CYGWIN__
> > >   use wint_t
> > >   #else
> > >   use wchar_t
> > >   #endif
> > >
> > > The header should be kept untouched, of course.
> > >
> > >
> > > Corinna
> > >
> > > --
> > > Corinna Vinschen
> > > Cygwin Maintainer
> > > Red Hat
>
> --
> Corinna Vinschen
> Cygwin Maintainer
> Red Hat