From owner-freebsd-questions Wed Jan 31 18:18: 2 2001 Delivered-To: freebsd-questions@freebsd.org Received: from guru.mired.org (okc-65-26-235-186.mmcable.com [65.26.235.186]) by hub.freebsd.org (Postfix) with SMTP id DC7C837B503 for ; Wed, 31 Jan 2001 18:17:44 -0800 (PST) Received: (qmail 43410 invoked by uid 100); 1 Feb 2001 02:17:44 -0000 From: Mike Meyer MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <14968.51016.322465.80746@guru.mired.org> Date: Wed, 31 Jan 2001 20:17:44 -0600 (CST) To: Lucas Bergman , t.vanklaveren@student.utwente.nl Cc: questions@freebsd.org Subject: Re: Printf question In-Reply-To: <109394@toto.iv> X-Mailer: VM 6.75 under 21.1 (patch 10) "Capitol Reef" XEmacs Lucid X-face: "5Mnwy%?j>IIV\)A=):rjWL~NB2aH[}Yq8Z=u~vJ`"(,&SiLvbbz2W`;h9L,Yg`+vb1>RG% *h+%X^n0EZd>TM8_IB;a8F?(Fb"lw'IgCoyM.[Lg#r\ Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Lucas Bergman types: > % cat foo.c > #include > > typedef unsigned long long uint64_t; > > struct thingy { > uint64_t r_id; > uint64_t c_id; > }; > > int > main(void) > { > struct thingy x; > struct thingy *res = &x; > x.r_id = 1; > x.c_id = 255676; > printf("result (result %ld, cid %ld)\n", res->r_id, res->c_id); > return 0; > } > % gcc -Wall foo.c > foo.c: In function `main': > foo.c:19: warning: long int format, different type arg (arg 2) > foo.c:19: warning: long int format, different type arg (arg 3) > > What you probably want is the `%llu' specifier instead of `%ld'. > Note that `long long' is a _very_ recent addition to the C standard, > so proceed with caution if you want your program to be portable. The man page doesn't mention ll as a modifier, but talks about q. I get the results he wants with %qd, %qu, or %llu - but not %lld. -Wall doesn't complain about either one (on -current, anyway). http://www.mired.org/home/mwm/ Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message