Date: Sun, 8 Jan 2006 18:41:21 +0100 From: Max Laier <max@love2party.net> To: freebsd-ports@freebsd.org Cc: Edwin Groothuis <edwin@mavetju.org> Subject: Re: time_t printf() Message-ID: <200601081841.28127.max@love2party.net> In-Reply-To: <20060108103402.GB3806@k7.mavetju> References: <20060108103402.GB3806@k7.mavetju>
next in thread | previous in thread | raw e-mail | index | archive | help
--nextPart4197074.XBX9P7DkuW Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline 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 =3D 0, hours =3D 0, minutes =3D 0, seconds =3D 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 =2D-=20 /"\ Best regards, | mlaier@freebsd.org \ / Max Laier | ICQ #67774661 X http://pf4freebsd.love2party.net/ | mlaier@EFnet / \ ASCII Ribbon Campaign | Against HTML Mail and News --nextPart4197074.XBX9P7DkuW Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.2 (FreeBSD) iD8DBQBDwU7IXyyEoT62BG0RAvrlAJ9x8Ek9AaR17HFeIR+TsNPmSU0kqwCdEiuk VwnugdKahfrEGynz82+Xsgw= =T7HY -----END PGP SIGNATURE----- --nextPart4197074.XBX9P7DkuW--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200601081841.28127.max>