This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: %d or %ld for datatype int?



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 Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]