From owner-freebsd-hackers@FreeBSD.ORG Sun Jun 5 20:40:34 2011 Return-Path: Delivered-To: hackers@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A853E106566B for ; Sun, 5 Jun 2011 20:40:34 +0000 (UTC) (envelope-from ben@links.org) Received: from mail.links.org (mail.links.org [217.155.92.109]) by mx1.freebsd.org (Postfix) with ESMTP id 5DFAB8FC14 for ; Sun, 5 Jun 2011 20:40:34 +0000 (UTC) Received: from [193.133.15.218] (localhost [127.0.0.1]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.links.org (Postfix) with ESMTPS id 58C7A33C1C; Sun, 5 Jun 2011 21:40:33 +0100 (BST) Message-ID: <4DEBE9C7.4030505@links.org> Date: Sun, 05 Jun 2011 21:40:39 +0100 From: Ben Laurie User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.2.17) Gecko/20110414 Thunderbird/3.1.10 MIME-Version: 1.0 To: "Sean C. Farley" References: <4DEBC741.1020200@links.org> In-Reply-To: X-Enigmail-Version: 1.1.1 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: hackers@FreeBSD.org Subject: Re: int64_t and printf X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 05 Jun 2011 20:40:34 -0000 On 05/06/2011 19:31, Sean C. Farley wrote: > On Sun, 5 Jun 2011, Ben Laurie wrote: > >> So, for example int64_t has no printf modifier I am aware of. Likewise >> its many friends. >> >> In the past I've handled this by having a define somewhere along the >> lines of... >> >> #if >> # define INT_64_T_FMT "%ld" >> #else >> # define INT_64_T_FMT "%lld" >> #endif >> >> but I have no idea where to put such a thing in FreeBSD. Opinions? >> Also, I guess I'd really need to do a modifier rather than a format, >> for full generality. > > You need to include inttypes.h, which includes machine/_inttypes.h. This > will provide the appropriate macro which in this case is PRId64. I somewhat love this plan. Apparently it doesn't work: /scratch/tmp/benl/work/head/cddl/lib/libdtrace/../../../cddl/contrib/opensolaris/lib/libdtrace/common/dt_subr.c:963:40: error: expected ')' (void) snprintf(c, sizeof (c), "0x%" PRIx64, addr); ^ (ref9-amd64). -- http://www.apache-ssl.org/ben.html http://www.links.org/ "There is no limit to what a man can do or how far he can go if he doesn't mind who gets the credit." - Robert Woodruff