h8300, m32c and PRIuPTR
Mon Mar 16 15:54:00 GMT 2015
On Mar 16 09:38, Joel Sherrill wrote:
> On 3/16/2015 9:10 AM, Eric Blake wrote:
> > On 03/16/2015 04:22 AM, Nicholas Clifton wrote:
> >> Hi Joel,
> >>> The warning is:
> >>> f.c:6:3: warning: format '%u' expects argument of type 'unsigned int',
> >>> but argument 2 has type 'uintptr_t' [-Wformat=]
> >>> printf( "%" PRIuPTR "\n", x );
> >>> Any ideas on how to address this?
> >> How about using an explicit widening cast, as in:
> >> printf ("%lu\n", (unsigned long) x);
> >> I am assuming that sizeof (uintptr_t) <= sizeof (unsigned long) will
> >> always be true, but that seems reasonable to me.
> > Not on 64-bit mingw (where sizeof(long)==4, sizeof(uintptr_t)==8). But
> > yes, explicitly widening to a known type can work around cases where you
> > are otherwise stumped, although for this particular code, it looks like
> > PRIuPTR is misdefined for your platform.
> And we don't want to add casts. We just want to use the PRIxxx constants
> to have portable printf formats and avoid warnings.
> I am wondering if when we avoided changing newlib-stdint.h to match the
> in glibc-stdint.h for uintptr_t by adding configure time logic, we just
> off the problem. At this point, all I can see as a solution is something
> like this
> in inttypes.h:
> #if defined(__m32c__) || defined(__h8300__)
> /* do whatever is needed */
> /* we can rely on the value provided by configure, use current logic */
Did you see my mail mentioning sys/config.h?
Again, the size of pointer values as well as the fact what multilib
we're building for should be available from gcc at compile time. This
information should ideally be used to influence the logic of inttypes.h
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 819 bytes
Desc: not available
More information about the Newlib