From owner-freebsd-current@FreeBSD.ORG Sun Feb 13 06:24:22 2005 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id C054816A4CE for ; Sun, 13 Feb 2005 06:24:22 +0000 (GMT) Received: from dragon.nuxi.com (trang.nuxi.com [66.93.134.19]) by mx1.FreeBSD.org (Postfix) with ESMTP id 9375D43D49 for ; Sun, 13 Feb 2005 06:24:22 +0000 (GMT) (envelope-from obrien@NUXI.com) Received: from dragon.nuxi.com (obrien@localhost [127.0.0.1]) by dragon.nuxi.com (8.13.1/8.13.1) with ESMTP id j1D6OKbN017725; Sat, 12 Feb 2005 22:24:20 -0800 (PST) (envelope-from obrien@dragon.nuxi.com) Received: (from obrien@localhost) by dragon.nuxi.com (8.13.1/8.13.1/Submit) id j1D6OJJf017724; Sat, 12 Feb 2005 22:24:19 -0800 (PST) (envelope-from obrien) Date: Sat, 12 Feb 2005 22:24:19 -0800 From: "David O'Brien" To: Joseph Koshy Message-ID: <20050213062419.GA83950@dragon.nuxi.com> References: <20050212145501.GG5488@cnd.mcgill.ca> <84dead720502122050492cde82@mail.gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <84dead720502122050492cde82@mail.gmail.com> User-Agent: Mutt/1.4.1i X-Operating-System: FreeBSD 6.0-CURRENT Organization: The NUXI BSD Group X-Pgp-Rsa-Fingerprint: B7 4D 3E E9 11 39 5F A3 90 76 5D 69 58 D9 98 7A X-Pgp-Rsa-Keyid: 1024/34F9F9D5 cc: freebsd-current@freebsd.org cc: Mathew Kanner Subject: Re: cross platform X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: obrien@freebsd.org List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 13 Feb 2005 06:24:22 -0000 On Sun, Feb 13, 2005 at 04:50:46AM +0000, Joseph Koshy wrote: > > - How do I know which is the right directive? Is this documented > > somewhere? > What's the problem exactly? > > I had a problem with printing uint64_t values portably between > the AMD 64 and i386. My debug printfs had to use either > "%lx" or "%llx". The workaround (hack) was to use CPP > liberally (#define U64FORMAT "%l" or "%ll"). > > I wonder if there is a better (more portable) way. The ISO C standard way is to use "PRIx64". See /usr/include/machine/_inttypes.h. The FreeBSD way is to use %jd and cast the value to (maxint_t). -- -- David (obrien@FreeBSD.org)