[libvirt] [PATCH libvirt 3/6] Fix warnings about pid_t printf format on mingw64

Eric Blake eblake at redhat.com
Thu Jan 26 00:54:19 UTC 2012


On 01/25/2012 05:22 PM, Marc-André Lureau wrote:
>> the decision should _not_ be based on _WIN64, but instead on a
>> configure-time test on the underlying type of pid_t.  And since
>> _that_
>> gets difficult, I'd almost rather go with the simpler approach of:
>>
>> "%" PRIdMAX, (intmax_t) pid
>>
>> everywhere that we currently use
>>
>> "%d", pid
>>
> 
> I thought about using that solution, but I prefer the format macro.

Yes, it would be nice if <inttypes.h> had a macro for id_t.  But even
then, pid_t, uid_t, and gid_t are not necessarily the same width as id_t
(id_t is necessarily as large as the other three, but they don't all
have to be the same size).  And it gets unwieldy fast if you start
introducing more macros for more types.

> Tbh, I wish some of these would be part of gnulib (perhaps some already are).

Sadly, no one has made a case for extended type macros in gnulib.  And
mingw points out the problem - we can't use "lld" nor PRIdMAX for pid_t,
since we don't know whether the code is targetting gnu printf, windows
printf, or a mix.  I really do think we're stuck with casting to (long
long) or (intmax_t) in this case :(

-- 
Eric Blake   eblake at 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: 620 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20120125/fbe34f08/attachment-0001.sig>


More information about the libvir-list mailing list