On 21 January 2013 17:56, Eric Blake <[email protected]> wrote:
> On 01/21/2013 08:48 AM, Peter Maydell wrote:
>> On 14 January 2013 23:08,  <[email protected]> wrote:
>>> +#define TYPE_VIRTIO_BUS "virtio-bus"
>>> +#define VIRTIO_BUS_GET_CLASS(obj) \
>>> +        OBJECT_GET_CLASS(VirtioBusClass, obj, TYPE_VIRTIO_BUS)
>>> +#define VIRTIO_BUS_CLASS(klass) \
>>> +        OBJECT_CLASS_CHECK(VirtioBusClass, klass, TYPE_VIRTIO_BUS)
>>
>> 'obj' and 'klass' need brackets round them, because they're
>> macro arguments.
>
> Brackets are only necessary if the C parser could misinterpret things
> without the brackets; but in this particular case, there is no ambiguity
> (unless OBJECT_GET_CLASS() and OBJECT_CLASS_CHECK() are improperly
> under-parenthesized).

Yes, but "we can get away without parens here because we know
that other macro over there has parens in it" is unnecessarily
tricky in my opinion.

-- PMM

Reply via email to