%d or %ld for datatype int?
Rich Johnson
rich@shawmutav.com
Mon Dec 22 22:13:00 GMT 2003
On Monday, December 22, 2003, at 03:51 PM, Eljay Love-Jensen wrote:
> Hi Rich,
>
> Try this:
> printf ( "%ld seconds into the epoch\n", (long int)now.tv_sec );
>
Thanks, I don't know why but it takes me a bit of effort to accept the
need for a cast--especially after all the effort that went into
typedefs for int32_t, __time_t, etc.
I rationalize the cast as producing "what printf" expects rather than
what "the data is". It also helps to realize that it will work with
64-bit architectures, no matter what __time_t is defined to be.
--rich
More information about the Gcc-help
mailing list