problem in deleting dll class object.(scalar deleting destructor)
-
HI, i am having problem with converting my c++ class to dll. The problem is the following. i have a class that i want to export, there are two private variables in the class, one of them is a struct. the variables are initialized in the constructor. In my ap, i created a object of my class and then delete it. Looks pretty straight forward, however, when deleting the object i get a error message "Debug Error". If i don't initialize the variables, delete is ok. if i memset the struct variable,i get a "scaler deleting destructor" error. Anyone got any idea why the dll behaves like this? ----------------------------------------AP------------------------------------ CIPCamDll *a = new CIPCamDll(); delete a; ---------------------------------------.h-------------------------------------- #ifdef IPCAMDLL_EXPORTS #define IPCAMDLL_API __declspec(dllexport) #else #define IPCAMDLL_API __declspec(dllimport) #endif typedef struct s { int abcd; }s; class IPCAMDLL_API CIPCamDll { public: CIPCamDll(void); CIPCamDll(char* para_address); ~CIPCamDll(void); private: int session_id; s m_t; }; -------------------------------------------------------------------------------- --------------------------.cpp--------------------------------------------------- CIPCamDll::CIPCamDll() { session_id = 13; return; } CIPCamDll::CIPCamDll(char* para_address) { return; } CIPCamDll::~CIPCamDll() { return; } ------------------------------------------------.cpp-------------------------------
-
HI, i am having problem with converting my c++ class to dll. The problem is the following. i have a class that i want to export, there are two private variables in the class, one of them is a struct. the variables are initialized in the constructor. In my ap, i created a object of my class and then delete it. Looks pretty straight forward, however, when deleting the object i get a error message "Debug Error". If i don't initialize the variables, delete is ok. if i memset the struct variable,i get a "scaler deleting destructor" error. Anyone got any idea why the dll behaves like this? ----------------------------------------AP------------------------------------ CIPCamDll *a = new CIPCamDll(); delete a; ---------------------------------------.h-------------------------------------- #ifdef IPCAMDLL_EXPORTS #define IPCAMDLL_API __declspec(dllexport) #else #define IPCAMDLL_API __declspec(dllimport) #endif typedef struct s { int abcd; }s; class IPCAMDLL_API CIPCamDll { public: CIPCamDll(void); CIPCamDll(char* para_address); ~CIPCamDll(void); private: int session_id; s m_t; }; -------------------------------------------------------------------------------- --------------------------.cpp--------------------------------------------------- CIPCamDll::CIPCamDll() { session_id = 13; return; } CIPCamDll::CIPCamDll(char* para_address) { return; } CIPCamDll::~CIPCamDll() { return; } ------------------------------------------------.cpp-------------------------------
Where is the memset? :)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
HI, i am having problem with converting my c++ class to dll. The problem is the following. i have a class that i want to export, there are two private variables in the class, one of them is a struct. the variables are initialized in the constructor. In my ap, i created a object of my class and then delete it. Looks pretty straight forward, however, when deleting the object i get a error message "Debug Error". If i don't initialize the variables, delete is ok. if i memset the struct variable,i get a "scaler deleting destructor" error. Anyone got any idea why the dll behaves like this? ----------------------------------------AP------------------------------------ CIPCamDll *a = new CIPCamDll(); delete a; ---------------------------------------.h-------------------------------------- #ifdef IPCAMDLL_EXPORTS #define IPCAMDLL_API __declspec(dllexport) #else #define IPCAMDLL_API __declspec(dllimport) #endif typedef struct s { int abcd; }s; class IPCAMDLL_API CIPCamDll { public: CIPCamDll(void); CIPCamDll(char* para_address); ~CIPCamDll(void); private: int session_id; s m_t; }; -------------------------------------------------------------------------------- --------------------------.cpp--------------------------------------------------- CIPCamDll::CIPCamDll() { session_id = 13; return; } CIPCamDll::CIPCamDll(char* para_address) { return; } CIPCamDll::~CIPCamDll() { return; } ------------------------------------------------.cpp-------------------------------
Make sure your exe and dll use the same variant (static/dynamic linking) of the C run-time library.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
-
Where is the memset? :)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles]HI, thanks for the reply, i put the memset in the constructor. i am guessing that it has something do to with different heap memory allocated for dll, and AP? --------------------------.cpp--------------------------------------------------- CIPCamDll::CIPCamDll() { memset(&m_t,0,sizeof(s)); session_id = 13; return; } ------------------------.cpp------------------------------------------