core.sys.windows.com.ComObject apparently has wrongly laid out Vtable

Carl Sturtivant sturtivant at gmail.com
Wed Mar 20 14:03:12 UTC 2024


On Wednesday, 20 March 2024 at 06:16:01 UTC, Richard (Rikki) 
Andrew Cattermole wrote:
> The only difference I'm aware of between a class that inherits 
> from IUnknown and extern(C++) should be the calling convention 
> used for the functions in the vtable.

Here's the interesting situation I mentioned, isolated, but with 
the C/Windows definition of the struct IUnknown placed in C 
source compiled with ImportC.

`comdef.c`
```C
#include <wtypes.h>

struct C_IUnknownVtbl {
         HRESULT (*QueryInterface)(C_IUnknown* This, IID* riid, 
void** ppvObject);
         ULONG (*AddRef)(C_IUnknown* This);
         ULONG (*Release)(C_IUnknown* This);
};

struct C_IUnknown {
     C_IUnknownVtbl* lpVtbl;
};
```


More information about the Digitalmars-d mailing list