core.sys.windows.com.ComObject apparently has wrongly laid out Vtable
Walter Bright
newshound2 at digitalmars.com
Thu Mar 21 03:38:18 UTC 2024
On 3/19/2024 10:56 PM, Carl Sturtivant wrote:
> On Wednesday, 20 March 2024 at 05:42:29 UTC, Carl Sturtivant wrote:
>> What are the Vtable differences that cause an extern(C++) ComObject to work
>> when calling AddRef when the druntime ComObject with extern(Windows) does not?
>
> I mean this of course in the context of the code in my original post in this
> thread.
> There casting a druntime ComObject to a pointer leads to a non-working AddRef,
> but casting a extern(C++) ComObject to a pointer leads to a working AddRef. I
> could speculate, but what are the actual rules operating that lead to this?
>
A com object is an interface, not a class. All com objects must derive from
core.sys.windows.unknwn.IUknown, or from an interface that derives from IUnknown.
IUnknown uses the extern (Windows) calling convention.
For com objects, slot 0 in the vtbl[] is for QueryInterface(), not the classinfo.
More information about the Digitalmars-d
mailing list