On 21/03/2018 17:11, Marc-André Lureau wrote:
> Hi
>
> On Wed, Mar 21, 2018 at 5:00 PM, Paolo Bonzini <[email protected]> wrote:
>> On 21/03/2018 16:55, Marc-André Lureau wrote:
>>> That would work with an anonymous union though:
>>>
>>> struct QObject {
>>> union {
>>> QType type;
>>> QType base;
>>> };
>>> size_t refcnt;
>>> };
>>>
>>> If it's acceptable, I think I'll take this approach.
>>
>> You don't need QEMU_GENERIC at all then, don't you?
>
> Ah ah, that's what I thought too, but the type of QObject * &x->base
> isn't QObject * :)
>
> I don't think we can fool it there (without loosing some type safety)
Hmm, perhaps by making it "struct {} base"?
Or even:
struct QObjectCommon {
QType type;
size_t refcnt;
}
struct QObject {
QObjectCommon base;
}
struct QString {
QObjectCommon base;
...
}
Paolo