duplicate FILE typedef, stdio.h and wchar.h

Corinna Vinschen vinschen@redhat.com
Thu Mar 5 14:55:00 GMT 2015


On Mar  4 11:35, Craig Howland wrote:
> 
> On 03/04/2015 05:07 AM, Corinna Vinschen wrote:
> >Hi Craig,
> >
> >On Mar  3 23:05, Craig Howland wrote:
> >>      stdio.h and wchar.h both have unconditional "typedef FILE __FILE"
> >>declarations, which causes GCC to error out if both are included to the same
> >>source, which happens in any number of newlib source files.  (For example,
> >>libc/stdlib/btowc.c.)
> >I'm rather puzzled by this observation.  As you may imagine, these files
> >are used for a long time in packages in the Cygwin distro, and if GCC
> >would error out in this simple case, we had a lot of complaints from
> >Cygwin package maintainers.  So the first question is, in which scenario
> >do you see this problem?  I created an STC:
> >
> >--8<---------------cut here---------------start------------->8---
> >#include <wchar.h>
> >#include <stdio.h>
> >
> >extern FILE *foo (FILE *);
> >
> >int main ()
> >{
> >   FILE *fp = foo (NULL);
> >   if (fp)
> >     foo (fp);
> >   return 0;
> >}
> >--8<---------------cut here---------------end--------------->8---
> >
> >and gcc -c -g -O2 -Wall does not error out, nor does it even produce
> >a warning.  Same when reordering the includes.  Not even with -ansi.
> I was quite surprised, too, but it's doing it (gcc 4.4.7 under RHEL6).  I
> fiddled with options a little to no avail, but decided it was easier to just
> fix it.

Does the above testcase fail the same way with this gcc?  If not,
it might be some different problem.  I wouldn't want to apply a
fix which just covers another problem, if possible.


Corinna

-- 
Corinna Vinschen
Cygwin Maintainer
Red Hat
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/newlib/attachments/20150305/4861384e/attachment.sig>


More information about the Newlib mailing list