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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]