From 330fadfc62498041c838cba3a0413bb9c715b73f Mon Sep 17 00:00:00 2001 From: Arjun Shankar Date: Mon, 18 May 2015 12:28:06 +0530 Subject: Ensure `wint_t' is defined before use in include/stdio.h 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. --- nptl/tst-initializers1.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'nptl') diff --git a/nptl/tst-initializers1.c b/nptl/tst-initializers1.c index e09f7a9c49..5119ebfcb5 100644 --- a/nptl/tst-initializers1.c +++ b/nptl/tst-initializers1.c @@ -30,8 +30,8 @@ pthread_rwlock_t rwl_writer = PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP; pthread_cond_t cond = PTHREAD_COND_INITIALIZER; -int -main (void) +static int +do_test (void) { if (mtx_normal.__data.__kind != PTHREAD_MUTEX_TIMED_NP) return 1; @@ -55,3 +55,6 @@ main (void) return 7; return 0; } + +#define TEST_FUNCTION do_test () +#include "../test-skeleton.c" -- cgit v1.2.3