This is the mail archive of the cygwin-developers mailing list for the Cygwin 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 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
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] |