stdint.h question
Eric Norum
norume at aps.anl.gov
Mon May 7 15:11:10 UTC 2007
On May 7, 2007, at 9:54 AM, Till Straumann wrote:
>>
> You are right, thx.
> Unfortunately, there still seems to be a bug in the newlib headers:
> Compiling the snippet
>
> #include <inttypes.h>
> #include <stdio.h>
>
> uintptr_t blah(void *arg)
> {
> uintptr_t rval = (uintptr_t)arg;
> printf("%"PRIxPTR"\n", rval);
> return rval;
> }
>
> produces:
>
> tst.c: In function 'blah':
> tst.c:7: warning: format '%llx' expects type 'long long unsigned int',
> but argument 2 has type 'uintptr_t'
>
> I.e., the formatting macro expands to 'unsigned long long int' but
> uintptr_t is only 'unsigned int'
> (which seems to be ok on a 32-bit machine).
>
> (gcc 4.1.1, newlib 1.14.0)
>
Seems to be fixed in the latest newlib (1.15.0 with rtems4.7-20070208
patch):
1) The format string seems correct:
> m68k-rtems4.7-gcc -E a.c | grep 'printf.*rval'
printf("%""lx""\n", rval);
2) And it compiles without warning:
> m68k-rtems4.7-gcc -Wall -c -O4 a.c
I got similar results with the powerpc and i386 cross-compilers.
--
Eric Norum <norume at aps.anl.gov>
Advanced Photon Source
Argonne National Laboratory
(630) 252-4793
More information about the users
mailing list