CBFalconer said:
Nate said:
... snip ...
I see no specification for time_t, other than arithmetic type,
so that conversion is probably accurate. However, there is no
specification whatsoever for suseconds_t.
The documentation for the Unix gettimeofday function says that
it is a signed integer type capable of representing the range
[-1,1000000], and the tv_usec member returned from gettimeofday
will have a value in that range. Given which, a cast to `long
int' should be good enough. (Just using %ld isn't enough,
though, because suseconds_t could also be a type smaller than
`long int'.)
While I assume you are quite correct for Unix, that discussion
belongs on comp.unix.programmer, not here.
There's a C question underlying it, though.
"If foo is a type, supplied by some library, which is known only
to be a signed integer capable representing the range [-1,1000000],
how can we print out a value of type foo, in a manner that will
continue to work if another version of the library should change
foo to a different type with the same property?"
Now replace foo with suseconds_t.