Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 31 Jan 2001 20:17:44 -0600 (CST)
From:      Mike Meyer <mwm@mired.org>
To:        Lucas Bergman <lucas@slb.to>, t.vanklaveren@student.utwente.nl
Cc:        questions@freebsd.org
Subject:   Re: Printf question
Message-ID:  <14968.51016.322465.80746@guru.mired.org>
In-Reply-To: <109394@toto.iv>

next in thread | previous in thread | raw e-mail | index | archive | help
Lucas Bergman <lucas@slb.to> types:
> % cat foo.c
> #include <stdio.h>
> 
> 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).

	<mike
--
Mike Meyer <mwm@mired.org>			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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?14968.51016.322465.80746>