[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v3 2/4] compiler: rework BUG_ON using a struct
From: |
Eric Blake |
Subject: |
Re: [Qemu-devel] [PATCH v3 2/4] compiler: rework BUG_ON using a struct |
Date: |
Fri, 20 Jan 2017 08:36:08 -0600 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.6.0 |
On 01/20/2017 03:41 AM, Dr. David Alan Gilbert wrote:
>> -#define QEMU_BUILD_BUG_ON(x) \
>> - typedef char glue(qemu_build_bug_on__, __LINE__)[(x) ? -1 : 1] \
>> - __attribute__((unused))
>> +#define QEMU_BUILD_BUG_ON_STRUCT(x) \
>> + struct { \
>> + int qemu_build_bug_on : (x) ? -1 : 1; \
>> + }
>
> The problem with this is it can't be used as an expression, where as
> your previous version could.
> I've got a similar case (see previous reply) that needed an expression
> bug-on that would evaluate to zero.
Keep reading the series - the version usable in an expression is
QEMU_BUILD_BUG_ON_ZERO, introduced in 3/4. Patch 2/4 is just rewriting
the existing check, with no change in the fact that it is still a
declaration.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature
Re: [Qemu-devel] [PATCH v3 0/4] ARRAY_SIZE fixups, Markus Armbruster, 2017/01/20