COM/OLE advanced questions

Guillaume Piolat contact at spam.com
Thu Nov 2 14:22:56 UTC 2017


I wonder if anyone has used COM in dlang extensively.

Context: I must use COM FFI interfacing on systems that aren't 
necessarily  Windows. It is essential that the layout of 
interfaces and classes are the same than in equivalent C++ 
objects.


Question 1. Is it mandatory to inherit from 
core.sys.windows.unknwn.IUnknown, or just having an interface 
named "IUnknown" validate it for being a COM interface?

    If yes, then how am I supposed to use COM interfaces in other 
OSes? core.sys.windows.unknwn.IUnknown is defined under 
version(Windows).

    I wonder what the exact compiler hook is.


Question 2. If this fails, may I emulate COM vtable layout with 
extern(C++) class? I wonder what the exact differences are anyway 
between extern(C++) and the special IUnknown.


Question 3. It seems I can inherit both from A D object and a COM 
interface. What will be the choosen layout?


More information about the Digitalmars-d-learn mailing list