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

Re: [libvirt] [PATCH 03/13] Rewrite virAtomic APIs using GLib's atomic ops code

On 07/20/2012 12:36 AM, Hu Tao wrote:

>>>> +#  define virAtomicIntGet(atomic)                                       \
>>>> +    (__extension__ ({                                                   \
>>>> +            verify (sizeof(*(atomic)) == sizeof(int));                  \
>>>> +            (void) (0 ? *(atomic) ^ *(atomic) : 0);                     \
>>>> +            __sync_synchronize ();                                      \
>>>> +            (int) *(atomic);                                            \
>>>> +        }))
>>> The `verify' lines cause building warnings:
>>> cc1: warnings being treated as errors
>>> util/virobject.c: In function 'virClassNew':
>>> util/virobject.c:74:99: error: nested extern declaration of '_gl_verify_function2' [-Wnested-externs]
>> Which version of gcc?

It turns out this is a problem with any gcc older than 4.6 (that is,
newer gcc with static_assert support no longer triggers this problematic
nested extern).  I was unable to come up with a way to avoid triggering
-Wnested-externs on older gcc without creating conflicting definitions.
 However, it's easy to work around in libvirt.  If -Wnested-externs is
in effect, then restrict the use of verify(...) to the top level
(outside of functions), and within functions, use this instead:


The cast to void is unfortunately necessary to avoid a -Wall of
'statement with no effect'.

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

Attachment: signature.asc
Description: OpenPGP digital signature

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