Any thought to making time_t 64 bits?
Schwarz, Konrad
konrad.schwarz@siemens.com
Mon Sep 21 14:22:00 GMT 2009
> 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
More information about the Newlib
mailing list