Date: Wed, 19 Feb 2003 15:28:38 -0500 (EST) From: Garrett Wollman <wollman@lcs.mit.edu> To: Johan Karlsson <johan@FreeBSD.ORG> Cc: freebsd-standards@FreeBSD.ORG Subject: Fwd: using 'PRIu64' from <inttypes.h> to get rid of warnings Message-ID: <200302192028.h1JKScdZ093213@khavrinen.lcs.mit.edu> In-Reply-To: <20030219201141.GA75809@numeri.campus.luth.se> References: <20030219201141.GA75809@numeri.campus.luth.se>
next in thread | previous in thread | raw e-mail | index | archive | help
<<On Wed, 19 Feb 2003 21:11:41 +0100, Johan Karlsson <johan@FreeBSD.ORG> said: > I'm resending this to standards with the hope that someone > here will know if this is accepted usaged of PRIu64 and others. PRIu64 is evil and rude. Please don't use it. The correct way to print an integer of (notionally) unknown width would be: printf("foo: %ju", (u_intmax_t)foo); /* for unsigned foo */ printf("foo: %jd", (intmax_t)foo); /* for signed foo */ ...unless the value is known to have one of the other two standard opaque integer types (ptrdiff_t and size_t), or the code path ensures that a smaller type is appropriate. For example: if (foo < expression_of_type_unsigned_int) { printf("foo is small (%u < %u)", (unsigned)foo, expression_of_type_unsigned_int); } (In this case, `expression_of_type_unsigned_int' might be a constant expression that is known to be small.) But unless this is in an inner loop, it's probably not worth optimizing even this much. Just use intmax_t. -GAWollman To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200302192028.h1JKScdZ093213>