
Originally Posted by
couling
How does that work between different compilers?
It's my understanding that anything object orientated cant be used as a DLL interface unless both DLL and calling code were written with the same compiler.
Or unless both follow the exact same standard.
Microsoft have specified how COM interfaces are implemented, so any compiler vendor can ensure that their compiler is compatible.
And yes internally it does end up being just function pointers. You can even call COM objects from C using structures containing function pointers.
For example, here's a super simple COM interface:
Code:
struct IDendros0200Content1 : public IUnknown
{
virtual HRESULT STDMETHODCALLTYPE get_Parent(IDendros0200Element1 **theParent) = 0;
};
The same can be expressed in C as:
Code:
struct IDendros0200Content1Vtbl
{
// IUnknown base class virtual functions
HRESULT ( STDMETHODCALLTYPE *QueryInterface )(IDendros0200Content1 * This, REFIID riid, void **ppvObject);
ULONG ( STDMETHODCALLTYPE *AddRef )(IDendros0200Content1 * This);
ULONG ( STDMETHODCALLTYPE *Release )(IDendros0200Content1 * This);
// IDendros0200Content1 virtual functions
HRESULT ( STDMETHODCALLTYPE *get_Parent )(IDendros0200Content1 * This, IDendros0200Element1 **theParent);
};
struct IDendros0200Content1
{
struct IDendros0200Content1Vtbl* lpVtbl;
};