Got a problem with using a DLL which is using std::list while inserting an element with push_front(), etc... DEF_EXPORT is defined as __declspec( dllexport ) while compiling DLL and set to __declspec( dllimport ) while linked into EXE
Following code in DLL-Header:
class DEF_EXPORT cElement {
string m_Name;
public:
cElement ( string sName );
~cElement ();
string getName();
};
class DEF_EXPORT cMainObject {
protected:
list<cElement*> m_List;
public:
cMainObject ();
~cMainObject ();
int addElement( string sName );
void delElement( string sName );
};
And here some code from the DLL-CPP-File:
EBYTE cMainObject::addElement( string sName ) {
cElement *hTmp;
hTmp = new cElement ( sName );
if( !hTmp ) return 0;
this->m_List.push_front( hTmp );
return 1;
}
Compiling the DLL and exporting the LIB is no problem at all... Now I want to actually use the cMainObject to add an element:
cMainObject *hObj = new cMainObject();
hObj->addElement( "test" );
Program will fail in cMainObject::addElement() on calling push_front()-method. I guess it has something to do with memory used by DLL and memory used by EXE. But I do not know what to do to make this work. Any suggestions?
Btw... I use VC 7.1 on WinXP with Built-In STL stuff. For DLL the configuration type is DLL (of course) and runtime library code generation is set to 'Multi-threading Debug DLL'. The EXE uses same code generation.