From owner-freebsd-standards Wed Feb 19 12:28:42 2003 Delivered-To: freebsd-standards@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 49DD137B401; Wed, 19 Feb 2003 12:28:41 -0800 (PST) Received: from khavrinen.lcs.mit.edu (khavrinen.lcs.mit.edu [18.24.4.193]) by mx1.FreeBSD.org (Postfix) with ESMTP id 1272E43F3F; Wed, 19 Feb 2003 12:28:40 -0800 (PST) (envelope-from wollman@khavrinen.lcs.mit.edu) Received: from khavrinen.lcs.mit.edu (localhost [IPv6:::1]) by khavrinen.lcs.mit.edu (8.12.6/8.12.6) with ESMTP id h1JKScbs093216 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=OK); Wed, 19 Feb 2003 15:28:39 -0500 (EST) (envelope-from wollman@khavrinen.lcs.mit.edu) Received: (from wollman@localhost) by khavrinen.lcs.mit.edu (8.12.6/8.12.6/Submit) id h1JKScdZ093213; Wed, 19 Feb 2003 15:28:38 -0500 (EST) (envelope-from wollman) Date: Wed, 19 Feb 2003 15:28:38 -0500 (EST) From: Garrett Wollman Message-Id: <200302192028.h1JKScdZ093213@khavrinen.lcs.mit.edu> To: Johan Karlsson Cc: freebsd-standards@FreeBSD.ORG Subject: Fwd: using 'PRIu64' from to get rid of warnings In-Reply-To: <20030219201141.GA75809@numeri.campus.luth.se> References: <20030219201141.GA75809@numeri.campus.luth.se> Sender: owner-freebsd-standards@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: 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