BUG: sys/stat.h interferes with time.h

Jeff Johnston jjohnstn@redhat.com
Mon Aug 21 22:25:00 GMT 2006


Scott Pakin wrote:
> I just started using newlib and ran across a problem.  If sys/stat.h is
> #include'd before time.h, then struct itimerval is left undeclared.  Here's
> a minimal example to reproduce the bug:
> 
>     #include <sys/stat.h>
>     #include <time.h>
> 
>     int main (void)
>     {
>       struct itimerval mytimer;
> 
>       return 0;
>     }
> 
> % gcc -c -I/usr/include/newlib newlib-failure.c
> newlib-failure.c: In function `main':
> newlib-failure.c:6: error: storage size of `mytimer' isn't known
> 
> Swap the order of the two #include lines and all is well.
> 
> Regards,
> -- Scott
> 
> P.S.  I tried this using a native Linux/x86 build of newlib using the CVS
> source checked out on 18Aug2006 (no configure options other than --prefix).
>

For x86-linux, newlib punts in many cases and uses system headers when 
compiling.  So, it often depends what levels of glibc and gcc you are 
running against.

I tried the test case on my FC4 system where I build/test newlib x86 
linux and no problem occurs.

I then switched over to a new FC6 system with glibc-2.4.90-22 and did:

-bash-3.1$ gcc -c test.c
test.c: In function ‘main’:
test.c:6: error: storage size of ‘mytimer’ isn’t known

As you can see, without using newlib at all, the error occurs so it isn't
a newlib issue.

-- Jeff J.




More information about the Newlib mailing list