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

Carl Sturtivant sturtivant at gmail.com
Wed Mar 20 05:42:29 UTC 2024


On Wednesday, 20 March 2024 at 05:26:19 UTC, Carl Sturtivant 
wrote:
> This being the case, how do C++ objects in D escape this 
> constraint when cast to a pointer? Remember the top post? 
> Redefining IUnknown and ComObject to have C++ linkage 
> eliminated the 16 byte offset when casting directly and not via 
> IUnknown, and the code worked.

Ah, I am jumping to conclusions above. The code worked. So a call 
to a working AddRef was found in the ComObject Vtable. Exactly 
the way it wasn't for the library code of a ComObject, where the 
IUnknown interface Vtable had to be found in order for a working 
AddRef to be called.

And your reply uses extern(C++) --- should have noticed that.

> Is there some reason why this arrangement is not used for COM 
> objects in D?

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?


More information about the Digitalmars-d mailing list