From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/2279 Path: news.gmane.org!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: type of wchar_t Date: Thu, 15 Nov 2012 08:26:03 -0500 Message-ID: <20121115132603.GG20323@brightrain.aerifal.cx> References: <20121115130950.17ed134c@keeper.home.local> <20121115115340.GH12537@port70.net> <20121115163631.0db22beb@keeper.home.local> 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 1352985979 5661 80.91.229.3 (15 Nov 2012 13:26:19 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 15 Nov 2012 13:26:19 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-2280-gllmg-musl=m.gmane.org@lists.openwall.com Thu Nov 15 14:26:30 2012 Return-path: Envelope-to: gllmg-musl@plane.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1TYzSa-0003Ta-TZ for gllmg-musl@plane.gmane.org; Thu, 15 Nov 2012 14:26:25 +0100 Original-Received: (qmail 10020 invoked by uid 550); 15 Nov 2012 13:26:15 -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 10012 invoked from network); 15 Nov 2012 13:26:15 -0000 Content-Disposition: inline In-Reply-To: <20121115163631.0db22beb@keeper.home.local> User-Agent: Mutt/1.5.21 (2010-09-15) Xref: news.gmane.org gmane.linux.lib.musl.general:2279 Archived-At: On Thu, Nov 15, 2012 at 04:36:31PM +0400, Yuri Kozlov wrote: > > so we either use the __WCHAR_TYPE__ defined by the > > compiler (when it's defined), or use the abi specs > > (which gives the align+size+sign information and > > hopefully compilers agree on a single int type when > > there are multiple choices) > > Thanks for clarification. > Hah, gcc emit a __WCHAR_TYPE__ for arm as unsigned. Wow. > $ arm-linux-gnueabi-gcc -dM -E - < /dev/null |grep __WCHAR_T > #define __WCHAR_TYPE__ unsigned int Yes. Whoever designed this aspect of the ARM EABI did not know what they were doing. They probably came from a Windows background where wchar_t is unsigned short (to be able to represent all of the Unicode BMP) and did not realize that making it unsigned is unnecessary and even harmful when it's 32-bit and thus able to store all of Unicode (and much more) in a signed type. As already explained, I wanted to just always use a signed type on musl, but since L"" must match the type of wchar_t* (otherwise, passing L"" to a function that expects wchar_t* is a constraint violation and the compiler should throw an error), we need the definition to agree with whatever the compiler thinks it is, and real-world compilers follow the EABI document that defines it as unsigned. Rich