Marc-André Lureau <marcandre.lur...@redhat.com> writes:

> By moving the base fields to a QObjectBase_, QObject can be a type
> which also has a 'base' field. This allows writing a generic QOBJECT()
> macro that will work with any QObject type, including QObject
> itself. The container_of() macro ensures that the object to cast has a
> QObjectBase_ base field, giving some type safety guarantees. QObject
> must have no members but QObjectBase_ base, or else QOBJECT() breaks.
>
> QObjectBase_ is not a typedef and uses a trailing underscore to make
> it obvious it is not for normal use and to avoid potential abuse.

The omission of typedef to signal "internal use" is unusual in QEMU.
Doesn't bother *me*, but then I wouldn't typedef any struct or union if
consistency with the bulk of QEMU's code didn't demand it.

I can add the typedef and update the commit message if desired.

> Signed-off-by: Marc-André Lureau <marcandre.lur...@redhat.com>
> Reviewed-by: Eric Blake <ebl...@redhat.com>

I would've been tempted to try an unnamed field, but (1) that might've
been too clever, and (2) this patch exists and works.

With or without the typedef:
Reviewed-by: Markus Armbruster <arm...@redhat.com>

Reply via email to