Mixin override function in a extern C++ class leads to possible bug?

Zoadian no at no.no
Mon Apr 3 11:24:16 UTC 2023


Hi, am I missing something or is this a bug?
I'm trying to load a C++ DLL (a vst3). and most of it works 
perfectly, but i've got a case where the order of two mixins 
suddenly matters, but they mixin override functions.
looks like somehow the vtable gets screwed up.
code is minified to explain whats going on, i can provide a 
complete compilabe project if nessecary.
am i correct that this is a bug and the order of the two mixins 
shouldn't matter?

```
extern (C++)
class HostMessage : IMessage
{
public:
   // somehow the order of the two mixins matters
   mixin IMPLEMENT_REFCOUNT;
   mixin QUERY_INTERFACE!(FUnknown, IMessage);
}

mixin template IMPLEMENT_REFCOUNT() {
   override uint addRef()  { return 1; }
   override uint release() { return 1; }
}

mixin template QUERY_INTERFACE(Interfaces...) {
   override tresult queryInterface (ref const TUID _iid, void** 
obj) { return 1; }
}

interface IMessage : FUnknown
{
public:
nothrow:
// @nogc:
	/** Returns the message ID (for example "TextMessage"). */
	FIDString getMessageID();

	/** Sets a message ID (for example "TextMessage"). */
	void setMessageID(FIDString id /*in*/);

	/** Returns the attribute list associated to the message. */
	IAttributeList getAttributes();

     __gshared immutable TUID iid = INLINE_UID(0x936F033B, 
0xC6C047DB, 0xBB0882F8, 0x13C1E613);
}

interface FUnknown : IUnknown {
     __gshared immutable TUID iid = INLINE_UID(0x00000000, 
0x00000000, 0xC0000000, 0x00000046);
}


interface IUnknown {
     tresult queryInterface(ref const(TUID) _iid, void** obj);
     uint addRef();
     uint release();
}
```


More information about the Digitalmars-d mailing list