Re: %d or %ld for datatype int?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




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


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux