qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH v4] build: Work around SIZE_MAX bug in OSX heade


From: Eric Blake
Subject: Re: [Qemu-devel] [PATCH v4] build: Work around SIZE_MAX bug in OSX headers
Date: Tue, 11 Oct 2016 09:27:41 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.3.0

On 10/11/2016 02:18 AM, Markus Armbruster wrote:

>> +#define SIZE_MAX ((sizeof(char)) * -1)
> 
> All right, let's see how this works.
> 

> 
> Cute, but what's wrong with straightforward
> 
>     #define SIZE_MAX ((size_t)-1)

I was trying to make the macro usable even in situations where 'size_t'
itself is undefined (because sufficient headers were not pre-included).
But you're right: <osdep.h> pulls in <sys/types.h>, and therefore size_t
is always available.  And since neither my solution nor your shorter
direct cast is usable in a preprocessor expression, neither has that
advantage in its favor (a solution that works in ALL scenarios required
by C99, at the expense of more text, would have an advantage).  So I
guess going with the shorter direct cast is just fine.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]