"Clive D.W. Feather" <clive@demon.net> writes:
No credit?
Sure. How about adding this comment? ** Thanks to Clive D.W. Feather for detailed technical ** advice about hosts with padding bits.
#ifndef HAVE_STDINT_H #define HAVE_STDINT_H (199901 <= __STDC_VERSION__)
19910L (can you say "16 bits"?)
No, 16 bits is a red herring. The expression is used only in preprocessor contexts, so arithmetic must be at least 32 bits (64 with C99) and the "L" is unnecessary. And even if the expression were used outside of preprocessor contexts, __STDC_VERSION__ can't be negative so the expression would still work. Anyway, I'll put the "L" in (if only to forestall pedantic bug reports :-).
if ((TYPE_BIT(time_t) <= LDBL_MANT_DIG && (TYPE_BIT(time_t) == LDBL_MANT_DIG || (TYPE_SIGNED(time_t) && UINTMAX_MAX / 2 < INTMAX_MAX)))
Why write this last test like this? UINTMAX_MAX and INTMAX_MAX are both going to be numbers of the form 2**N-1. Furthermore, UINTMAX_MAX >= INTMAX_MAX. So that last one can be done as UINTMAX_MAX == INTMAX_MAX.
It's just a style thing, as the two expressions are logically equivalent under the constraints that you mention. "UINTMAX_MAX / 2 < INTMAX_MAX" is more closely related to the constraints that were in my head when I wrote the code for the case where uintmax has padding bits and time_t is signed.