[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH] QEMU_BUILD_BUG_ON: use __COUNTER__
From: |
Peter Maydell |
Subject: |
Re: [Qemu-devel] [PATCH] QEMU_BUILD_BUG_ON: use __COUNTER__ |
Date: |
Tue, 31 Jan 2017 16:54:50 +0000 |
On 31 January 2017 at 16:37, Eric Blake <address@hidden> wrote:
> On 01/31/2017 10:07 AM, Markus Armbruster wrote:
>>> I tried that first thing.
>>> This generates lots of warnings if you have multiple users
>>> within a function: gcc is unhappy about the redundant extern
>>> declarations.
>>
>> #define QEMU_BUILD_BUG_ON(x) \
>> _Pragma("GCC diagnostic push") \
>> _Pragma("GCC diagnostic ignored \"-Wredundant-decls\"") \
>> extern char qemu_build_bug_on_[QEMU_BUILD_BUG_ON_ZERO((x))]
>> __attribute__((unused)); \
>> _Pragma("GCC diagnostic pop")
>
> Do we know if pragma GCC diagnostic push is supported in our minimum
> compiler requirements (gcc 4.1, and presumably clang just ignores the
> pragma)?
Nope; that's gcc 4.6 or newer. They're also a bit flaky between
gcc and clang because they rely on the warning being the same
in both cases. Using them in QEMU_BUILD_BUG_ON would be
massively overkill, especially since gcc 4.6 and on support
_Static_assert() which will get us better error messages
than this stuff.
thanks
-- PMM
Re: [Qemu-devel] [PATCH] QEMU_BUILD_BUG_ON: use __COUNTER__, Markus Armbruster, 2017/01/31
Re: [Qemu-devel] [PATCH] QEMU_BUILD_BUG_ON: use __COUNTER__, Peter Maydell, 2017/01/31
Re: [Qemu-devel] [PATCH] QEMU_BUILD_BUG_ON: use __COUNTER__, Daniel P. Berrange, 2017/01/31