From owner-svn-src-all@FreeBSD.ORG Fri Apr 16 09:33:00 2010 Return-Path: Delivered-To: svn-src-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 39046106566C; Fri, 16 Apr 2010 09:33:00 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail01.syd.optusnet.com.au (mail01.syd.optusnet.com.au [211.29.132.182]) by mx1.freebsd.org (Postfix) with ESMTP id C17258FC16; Fri, 16 Apr 2010 09:32:59 +0000 (UTC) Received: from c122-106-149-225.carlnfd1.nsw.optusnet.com.au (c122-106-149-225.carlnfd1.nsw.optusnet.com.au [122.106.149.225]) by mail01.syd.optusnet.com.au (8.13.1/8.13.1) with ESMTP id o3G9WtAV019423 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 16 Apr 2010 19:32:57 +1000 Date: Fri, 16 Apr 2010 19:32:55 +1000 (EST) From: Bruce Evans X-X-Sender: bde@delplex.bde.org To: David Schultz In-Reply-To: <20100415212734.GA17239@zim.MIT.EDU> Message-ID: <20100416185222.X1124@delplex.bde.org> References: <201003310212.o2V2CO7b063419@svn.freebsd.org> <20100415212734.GA17239@zim.MIT.EDU> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: Juli Mallett , svn-src-head@FreeBSD.org, svn-src-all@FreeBSD.org, src-committers@FreeBSD.org Subject: Re: svn commit: r205954 - head/include X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 16 Apr 2010 09:33:00 -0000 On Thu, 15 Apr 2010, David Schultz wrote: > On Wed, Mar 31, 2010, Juli Mallett wrote: >> Be like stdlib.h and bring in a wchar_t definition and use it to prototype >> wcstoimax and wcstoumax, rather than spelling it __wchar_t. This is necessary >> to use these functions in C++ where wchar_t is different to __wchar_t and is >> a built-in type. > > I don't think this change is correct for C mode. POSIX says > wchar_t is *supposed* to be defined by stdlib.h and wchar.h, but ^stddef.h, > its definition is namespace pollution elsewhere. C99 says the same, at least in old drafts. C99 also says that for the functions in that use wchar_t, both and must be included (by giving both of these headers in the synopses for these functions, and no explicit alternatives anywhere). However, this is unusable and close to unimplementable, especially the latter: - including without including should work when these functions are not used. FreeBSD used to use the usual implementation involving underscored named to make this case works without polluting with wchar_t. It is hard to make this case work while detecting the error in the case where these functions are used but is not included. - it is even harder and even sillier to detect the error in the case where these functions are used and some other header that declares wchar_t is included, but is not included :-). Perhaps fine print in C99 overrides the silly literal requirement, but I couldn't find it. POSIX (at least in old 2001 draft 7) is only slightly different here. It only mentions in the synopses, but gives in examples. But current POSIX (at least in the most recent html man page for wcstoimax found by google) has caught down to C99: it now specifies and in the synopsis, and doesn't say anything about alternatives to in the synopses, and doesn't say anything special about wchar_t. I couldn't find anything useful about this problem using google. I found mainly confusion about it in FOSS mailing lists, with no signs of standards being aware of it. IMO, the functions using wchar_t should never have been put in . The corresponding problem for was carefully avoided by putting all the stdio functions that use wchar_t in (where it causes corresponding problems for stdio types like FILE (*)). However, these functions have been misplaced for so long that the shouldn't be moved, and the easiest fix is to standardize the pollution. (*) The problems for FILE in are handled equally badly by standards and equally well by FreeBSD (compared with old-FreeBSD for wchar_t in ). FILE would be namespace pollution in , and FreeBSD is careful not to add it, and standards require inclusion of both and before using functions that use both FILE and wchar_t, but the latter is unusuable and close to unimplementable, as above. Now the functions are reasonably well placed (you wouldn't want a header just to hold them), and again the easiest fix is to standardize the pollution. At least the pollution wouldn't go all the way to . Bruce