time_t printf()
Max Laier
max at love2party.net
Sun Jan 8 09:41:03 PST 2006
On Sunday 08 January 2006 11:34, Edwin Groothuis wrote:
> Trying to printf() a time_t value, I tried the following permutations:
>
> time_t days = 0, hours = 0, minutes = 0, seconds = 0;
> sprintf(buffer, "%2d %2u %2ld %2lu", days, hours, minutes, seconds);
>
> 4.11 said:
> misc.c:117: warning: int format, time_t arg (arg 3)
> misc.c:117: warning: unsigned int format, long unsigned int arg (arg 4)
>
> 6.0 said:
> misc.c:117: warning: long int format, time_t arg (arg 5)
> misc.c:117: warning: long unsigned int format, time_t arg (arg 6)
>
> So between 4.11 and 6.0 there is no uniform way to printf() time_t
> values...
time_t is a bitch. The safest way should be:
"%lld", (long long int)foo
if you have C99 (not sure if that is given for 4.x):
"%jd", (intmax_t)foo
--
/"\ Best regards, | mlaier at freebsd.org
\ / Max Laier | ICQ #67774661
X http://pf4freebsd.love2party.net/ | mlaier at EFnet
/ \ ASCII Ribbon Campaign | Against HTML Mail and News
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-ports/attachments/20060108/ebc01882/attachment.bin
More information about the freebsd-ports
mailing list