[RFC] [PATCH] Ensure `wint_t' is defined before use in include/stdio.h

Siddhesh Poyarekar siddhesh@redhat.com
Wed May 13 10:00:00 GMT 2015


On Tue, May 12, 2015 at 01:54:20PM +0000, Arjun Shankar wrote:
> While trying to get nptl/tst-initializers1.c to include the test skeleton, I
> came across a couple of speed bumps. Firstly: after making the appropriate
> changes to the test, running `make check' led to this error:
> 
> > In file included from ../malloc/malloc.h:24:0,
> ..
> >                  from tst-initializers1.c:60:
> > ../include/stdio.h:111:1: error: unknown type name `wint_t'
> >  extern wint_t __getwc_unlocked (FILE *__fp);
> 
> So, `wint_t' is used before being defined. Question: Why did test-skeleton.c
> not cause this error in any of the other tests that include it?
> 
> Anyway, I noticed include/stdio.h includes stddef.h, which in turn defines
> `wint_t', but only if `__need_wint_t' is defined. So I put in a 
> `#define __need_wint_t' before the include to get rid of the error. Is that
> the correct fix?
> 
> A subsequent `make && make check' led to this second error:
> 
> >                  from tst-initializers1-c89.c:1:
> > ../test-skeleton.c: In function `main':
> > ../test-skeleton.c:356:11: error: `for' loop initial declarations are only
> >  allowed in C99 mode
> >            for (struct temp_name_list *n = temp_name_list;
> 
> Although there seem to be several other C89 no-noes in test-skeleton.c, I
> needed only to fix this specific one for gcc-4.8.3 to stop complaining.
> 
> And finally: The attached patch was tested on x86_64 with no regressions.
> 
> ChangeLog:
> 
> 2015-05-12  Arjun Shankar  <arjun.is@lostca.se>
> 
> 	* include/stdio.h: Define __need_wint_t.
> 	* test-skeleton.c: Avoid `for' loop initial declaration.
> 	* Use test-skeleton.c.

Looks fine to me.  I wondered if modifying test-skeleton.c to allow it
to be built in c89 is worth it, but I concluded that it is fine.  I'll
commit this by the end of the week.

Siddhesh
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 473 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/libc-alpha/attachments/20150513/bf4c152c/attachment.sig>


More information about the Libc-alpha mailing list