This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
| Other format: | [Raw text] | |
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
Attachment:
signature.asc
Description: OpenPGP digital signature
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |