Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 14 Nov 2011 14:19:14 -0500
From:      David Schultz <das@freebsd.org>
To:        David Chisnall <theraven@freebsd.org>
Cc:        svn-src-head@freebsd.org, svn-src-all@freebsd.org, Stefan Farfeleder <stefanf@freebsd.org>, Dimitry Andric <dim@freebsd.org>, src-committers@freebsd.org
Subject:   Re: svn commit: r227487 - head/include
Message-ID:  <20111114191914.GA58676@zim.MIT.EDU>
In-Reply-To: <3B8C1412-E18D-47E3-A09D-4847DD078963@FreeBSD.org>
References:  <201111131618.pADGIm2n099696@svn.freebsd.org> <20111114082129.GA1596@mole.fafoe.narf.at> <4EC0E6C2.4010509@FreeBSD.org> <20111114180235.GA58284@zim.MIT.EDU> <3B8C1412-E18D-47E3-A09D-4847DD078963@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, Nov 14, 2011, David Chisnall wrote:
> On 14 Nov 2011, at 18:02, David Schultz wrote:
> 
> > On Mon, Nov 14, 2011, Dimitry Andric wrote:
> >> On 2011-11-14 09:21, Stefan Farfeleder wrote:
> >>> On Sun, Nov 13, 2011 at 04:18:48PM +0000, David Chisnall wrote:
> >>>> Author: theraven
> >>>> Date: Sun Nov 13 16:18:48 2011
> >>>> New Revision: 227487
> >>>> URL: http://svn.freebsd.org/changeset/base/227487
> >>>> 
> >>>> Log:
> >>>>  The spec says that FILE must be defined in wchar.h, but it wasn't.  It
> >>>>  is now.  Also hide some macros in C++ mode that will break C++
> >>>>  namespaced calls.
> >>>> 
> >>>>  Approved by:	dim (mentor)
> >>> 
> >>> I think this change is wrong. Whic spec are you referring to? C99
> >>> defines FILE only in 7.19.1#2 (stdio.h). In other headers FILE is used
> >>> as parameter type for functions but that does not mean it is exported to
> >>> user space.
> >> 
> >> http://pubs.opengroup.org/onlinepubs/007908799/xsh/wchar.h.html
> > 
> > It's a niggling detail, but that's an extension to the C standard,
> > so properly speaking, it belongs in an
> >  #if __POSIX_VISIBLE >= 200809 || XSI_VISIBLE
> > (or something like that).  The formals were struct __sFILE *
> > instead of FILE * for that reason -- see r103177.
> > 
> > P.S. You're looking at a very old version of POSIX.  Check out:
> >     http://pubs.opengroup.org/onlinepubs/9699919799/
> 
> The C99 and C1x specifications both seem to require stdio.h to be included before wchar.h.  I think this therefore places including wchar.h and not stdio.h in the category of undefined (or, at least, not defined) behaviour, so we are free to do anything in this case.  I would say that accepting the code and working as the programmer expected is the least harmful thing to do here.  This is what Darwin libc does (actually, it #includes stdio.h in wchar.h).  

The C99 standard has plenty of examples of programs including
<wchar.h> but not <stdio.h>.  The latter is only required to call
the functions that take a FILE * parameter.  It's mostly an
academic point because no sane programmer would ever create a new
type named FILE, but FreeBSD actually did right by C99 before you
reverted r103177.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20111114191914.GA58676>