Build error for wcwidth and gcvt

Kota Uchida
Sat Jul 20 08:50:00 GMT 2019

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

I encountered 2 errors about wcwidth and gcvt.
I've pushed simple patches to forked repository:

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.

More information about the Newlib mailing list