CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 15 of 37

Threaded View

  1. #18
    Join Date
    Apr 2004
    Location
    England, Europe
    Posts
    2,492

    Re: problem with freeing memory in dll

    Quote Originally Posted by couling View Post
    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;
    };
    Last edited by Zaccheus; November 14th, 2009 at 06:21 AM.
    My hobby projects:
    www.rclsoftware.org.uk

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured