This is the mail archive of the
newlib@sourceware.org
mailing list for the newlib project.
RE: Any thought to making time_t 64 bits?
- From: "Schwarz, Konrad" <konrad dot schwarz at siemens dot com>
- To: Christopher Faylor <cgf-use-the-mailinglist-please at sourceware dot org>, "newlib at sourceware dot org" <newlib at sourceware dot org>
- Date: Mon, 21 Sep 2009 08:48:26 +0200
- Subject: RE: Any thought to making time_t 64 bits?
- References: <20090921022326.GA32207@ednor.casa.cgf.cx>
> Eric Blake just sent a query to the cygwin mailing list asking
> if there had been any thought given to making time_t 64 bits.
Without having looked at newlib from this angle, can't we have both? :-)
What I have done in code that is supposed to be highly portable is to define a macro indicating the maximum value a type (e.g., time_t) may have. Using the limits of the standard types defined in <limits.h>, conditional compilation can then be used to select the smallest integral type for the time_t typedef larger than or equal to this maximum value. At the same time, any auxiliary definitions that might be needed, such as printf()/scanf() h/l conversion specifier length modifiers can be defined.
This does have the disadvantage of introducing <limits.h>'s names into the user's namespace, but perhaps newlib has some way around this; an imperfect solution is to use the similarly-named macros defined by default by GCC. Alternatively, one could # undef all macros defined by <limits.h> after using it; however, this requires that reinclusion of <limits.h> redefines these values, e.g., they are defined outside any reinclusion guards that might exist in that file.
Regards,
Konrad Schwarz