This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: PATCH: Add x32 support to dynamic linker audit
On Wed, Mar 21, 2012 at 2:39 PM, Carlos O'Donell
<carlos@systemhalted.org> wrote:
> On Wed, Mar 21, 2012 at 5:35 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
>> %lx is wrong for uint64_t, which may be long long, not
>> long.
>
> Yes, that was a typo I should have printed %llx.
But %llx is wrong for unsigned long:
[hjl@gnu-6 tmp]$ cat b.c
#include <stdio.h>
#include <stdint.h>
void
b2 (uint64_t x)
{
printf ("%llx\n", x);
}
[hjl@gnu-6 tmp]$ gcc -Wall -c b.c
b.c: In function ‘b2’:
b.c:7:3: warning: format ‘%llx’ expects argument of type ‘long long
unsigned int’, but argument 2 has type ‘uint64_t’ [-Wformat]
[hjl@gnu-6 tmp]$
We need to cast to long long for %llx.
> So was %tu and ptrdiff_t chosen because they conveniently match the
> type to be printed no matter the architecture?
>
> Even though the meaning of ptrdiff_t isn't really what we intend here?
>
I don't have the answers.
--
H.J.