On Wed, 8 Jun 2005, Michael Haardt wrote:
> It won't work correctly in those environments, where the number of
> mantissa bits in a double is less than the number of bits in an off_t.
> On many systems, both types have the same size, so you lose as much
> accuracy as sign and offset take.
Sigh.
On Wed, 8 Jun 2005, Greg A. Woods wrote:
> You don't need C99 to make printf()'s portable for integer types that
> might have different widths on different platforms -- only C89! :-)
>
> ... or at least support in the compiler for concatenating adjacent
> strings.
That is indeed part of C89.
> in some application-specific portability header:
>
> #ifdef OFF_T_IS_LONG_LONG
> # define MY_OFF_T_FMT "%lld"
> #endif
> #ifdef OFF_T_IS_LONG
> # define MY_OFF_T_FMT "%ld"
> #endif
I did discover that gcc has %lld but of course that isn't part of C89,
so I suspect that there are C systems out there that don't have it.
However, I think one can hope that those systems that support long long
in the first place will also support %lld. Therefore, I think that your
suggestion of parameterizing this is probably the right way to go. It
would be nice if there was an automatic way of determining what the
type of off_t is. I will see if I can figure out something. I suppose
one fudge would be to inspect the sizeof() an off_t variable.
--
Philip Hazel University of Cambridge Computing Service,
ph10@??? Cambridge, England. Phone: +44 1223 334714.