sys/reent.h and time.h
geoffb@bops.com
geoffb@bops.com
Tue Aug 14 18:11:00 GMT 2001
> From: J. Johnston [ mailto:jjohnstn@cygnus.com ]
>
> geoffb@bops.com wrote:
> >
> > The comment at the top of sys/reent.h says:
> >
> > /* WARNING: All identifiers here must begin with an
> underscore. This file
> > is
> > included by stdio.h and others and we therefore must
> only use identifiers
> > in the namespace allotted to us. */
> >
> > but reent.h includes time.h (presumably to get `struct tm')
> which brings in
> > quite a few identifiers that don't begin with an
> underscore. The upshot is
> > the following program won't compile:
> >
> > #include <stdio.h>
> >
> > int
> > main ()
> > {
> > int time = 0;
> > printf ("%d", time);
> > }
> >
> > since time is defined in time.h.
> >
> > Is this a known problem? What is the best approach to fixing this?
> >
> > Please CC me as I'm not on the list (yet).
> >
>
> IMO the best way to fix this is to do what gcc does with
> stddef.h when it
> only wants to have size_t declared. A __need_struct_tm
> setting before including
> time.h should remove all but the desired type declaration. I
> have attached such a
> patch, but I haven't tested it yet.
>
> -- Jeff J.
But then you still get struct tm in your namespace. What I ended
up doing was declaring a struct _tm that matches struct tm and
casting it to struct tm in lcltime.c.
--
Geoff Berry
More information about the Newlib
mailing list