h8300, m32c and PRIuPTR

Eric Blake eblake@redhat.com
Mon Mar 16 14:38:00 GMT 2015

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.

Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 604 bytes
Desc: OpenPGP digital signature
URL: <http://sourceware.org/pipermail/newlib/attachments/20150316/73005bf5/attachment.sig>

More information about the Newlib mailing list