Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. problem in deleting dll class object.(scalar deleting destructor)

problem in deleting dll class object.(scalar deleting destructor)

Scheduled Pinned Locked Moved C / C++ / MFC
c++helpdebuggingquestion
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • U Offline
    U Offline
    User 404410
    wrote on last edited by
    #1

    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-------------------------------

    CPalliniC S 2 Replies Last reply
    0
    • U User 404410

      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-------------------------------

      CPalliniC Offline
      CPalliniC Offline
      CPallini
      wrote on last edited by
      #2

      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]

      In testa che avete, signor di Ceprano?

      U 1 Reply Last reply
      0
      • U User 404410

        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-------------------------------

        S Offline
        S Offline
        Stuart Dootson
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0
        • CPalliniC CPallini

          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]

          U Offline
          U Offline
          User 404410
          wrote on last edited by
          #4

          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------------------------------------------

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups