From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/7078 Path: news.gmane.org!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: wchar_t and -fshort-wchar Date: Thu, 19 Feb 2015 23:26:02 -0500 Message-ID: <20150220042602.GQ23507@brightrain.aerifal.cx> References: <20150218105337.GA8567@zx-spectrum> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1424406426 19051 80.91.229.3 (20 Feb 2015 04:27:06 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 20 Feb 2015 04:27:06 +0000 (UTC) Cc: musl@lists.openwall.com To: Sergey Dmitrouk Original-X-From: musl-return-7091-gllmg-musl=m.gmane.org@lists.openwall.com Fri Feb 20 05:27:05 2015 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1YOfBB-0006Kg-KA for gllmg-musl@m.gmane.org; Fri, 20 Feb 2015 05:27:05 +0100 Original-Received: (qmail 12216 invoked by uid 550); 20 Feb 2015 04:26:34 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 10195 invoked from network); 20 Feb 2015 04:26:17 -0000 Content-Disposition: inline In-Reply-To: <20150218105337.GA8567@zx-spectrum> User-Agent: Mutt/1.5.21 (2010-09-15) Original-Sender: Rich Felker Xref: news.gmane.org gmane.linux.lib.musl.general:7078 Archived-At: On Wed, Feb 18, 2015 at 12:53:37PM +0200, Sergey Dmitrouk wrote: > Hi, > > musl seems to build fine with -fshort-wchar, but when client applications > are built against musl all uses of wide character literals fail due to wide > type defined internally by a compiler differs from the type of `wchar_t` in > musl headers. > > I faced this on ARM where `wchar_t` is defined as `unsigned int` by > musl but it's `unsigned short` from compilers point of view. I'd expect > similar issues with other targets. > > Would it make sense to use `__WCHAR_TYPE__` for `wchar_t` when it's > available (it's already used for i386, but for different reason)? > Presumably, as compiler is responsible for creating wide literals, libc > would better agree with it on the type. > > Of course, this makes sense only if you intend to support builds with > `-fshort-wchar` flag, which are not very common I believe. musl does not support configurations with under-sized definitions of types like 16-bit wchar_t or 32-bit off_t. Only the sizes that can represent the full range of values are supported. musl does however have the C11 uchar.h functions which can operate on char16_t, so you could use char16_t and the corresponding c16 conversion functions instead of the wc versions if that helps. What are you trying to achieve? Rich