C++ Compiler independent Dll using abstract interface

273 Views Asked by At

Overflow community,

In my company, we want to move away from Borland C++-Compiler and Embarcadero-IDE. To do this slowly, I wanted to make each Dialog a Dll compiled with Microsoft Visual Studio C++-Compiler. Now in the DLL I have a function (These functions should Pop up the dialogs, here this is just a test)

extern "C" GETSELOBJSHARED_EXPORT void printSelectedObject(IAtml *Atml);

IAtml is an Interface and serves to make Callbacks to our Main-Application written in Borland, behind this Interface stands class Atml : public IAtml compiled in Borland. I thought this might work because of http://www.codeproject.com/Articles/28969/HowTo-Export-C-classes-from-a-DLL#CppMatureApproach).

Now if i call this function from the main application, it works if printSelectedObject has the following implementation

void  printSelectedObject(IAtml *Atml)
{
int selectedObject = Atml->GetSelObj();
}

but any line I add to that makes the Programm Crash, e.g.

void  printSelectedObject(IAtml *Atml)
{
OutputDebugString(L"Trying to call the Interface function!");
int selectedObject = Atml->GetSelObj();
}

The Interface contains only one function, so

struct IAtml
 {
   virtual int GetSelObj() = 0;
 } 

So why doesn't this work, are there any Workarounds. Can I use COM to achieve the same Thing. Any help is appreciated.

0

There are 0 best solutions below