src/winsup/utils ChangeLog.64bit cygcheck.cc l ...
Eric Blake
eblake@redhat.com
Wed Feb 6 18:33:00 GMT 2013
On 02/06/2013 10:57 AM, Corinna Vinschen wrote:
>> - printf ("ldd: GetModuleFileName returned an error %lu\n",
>> GetLastError ());
>> + printf ("ldd: GetModuleFileName returned an error %" PRIu32 "\n",
>> + (unsigned int) GetLastError ());
>>
>> PRIu32 is for uint32_t, not unsigned int; and on platforms where
>> uint32_t is unsigned long, you've ended up causing a compiler warning.
>> If you are going to cast GetLastError(), then just use %u; no need to
>> drag in <inttypes.h>.
>
> I changed that in ldd.cc. Other than that, We *know* that DWORD is
> declared as unsigned long on 32 bit, but as unsigned int on 64 bit,
> because sizeof long == 64 on x86_64-pc-cygwin. Therefore I'm using
> the PRIu32 and PRIx32 to make sure that I have the right format
> specifier for a known 32 bit variable, which uses a different type
> on different platforms.
If DWORD were defined as uint32_t, then this would work without
questions. But because DWORD is defined as 'unsigned long' vs.
'unsigned int', rather than uint32_t, your trick of using PRIu32 will
only work if we also ensure that uint32_t is defined to the same type as
DWORD. I guess we could get away with that, but it is rather subtle.
If we go with that approach, then it would be sufficient to write:
printf("%" PRIu32 "\n", GetLastError ())
But if we are worried that DWORD and uint32_t can ever be defined
independently, then we risk mismatch between long and int on 32-bit
platforms, even though we know both types are 32-bits, and it is that
type mismatch that gcc warns about.
Anyways, thanks for the followup patch.
--
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: 621 bytes
Desc: OpenPGP digital signature
URL: <http://cygwin.com/pipermail/cygwin-developers/attachments/20130206/6a5b9e22/attachment.sig>
More information about the Cygwin-developers
mailing list