[問題] 關於DLL的問題

看板C_and_CPP (C/C++)作者 (阿緯)時間15年前 (2010/09/15 21:59), 編輯推噓1(109)
留言10則, 3人參與, 最新討論串1/1
( *[1m *[m 為色碼,可以按 Ctrl+V 預覽會顯示的顏色 ) ( 未必需要依照此格式,文章條理清楚即可 ) 遇到的問題: (題意請描述清楚) 使用DLL執行結束會一直出現錯誤(assertion failed dbgheap) 這幾天查了很久 覺得程式碼也沒有問題可是不知道為麼會有這個關於point的問題 希望得到的正確結果: 程式執行都沒有問題 可是回到主程式一定會跳出這個訊息 程式跑出來的錯誤結果: "Debug assertion failed in dbgheap.c" dbgheap.c這是內建函式 所以我即使用debug模式也沒辦法回去source哪裡有問題 話說都是組合語言碼 我也看不是很懂@@ 開發平台: (例: VC++ or gcc/g++ or Dev-C++, Windows or Linux) VC6.0 ((公司要求ˊˋ 有問題的code: (請善用置底文標色功能) 這是.h的部分 #ifndef LineInterpreterProxy_H #define LineInterpreterProxy_H #include "LineInterpreter.h" using namespace std; #define Interpreter_CALL __stdcall #ifdef Interpreter_EXPORTS #define Interpreter_API __declspec(dllexport) #else #define Interpreter_API __declspec(dllimport) #endif class Interpreter_API LineInterpreterProxy{ public: LineInterpreterProxy(); // constructor void Interpreter_CALL excute(string input); private: LineInterpreter *li; }; #endif .cpp的部分 #define Interpreter_EXPORTS #include "LineInterpreterProxy.h" #include "iostream" using namespace std; LineInterpreterProxy::LineInterpreterProxy() { } void LineInterpreterProxy::excute(string input) { cout<<"test"; } 補充說明: 有正確印出test可是一定會出現那個錯誤訊息 小弟研究了好久 實在不曉得哪裡有寫錯@@ 請各位大大幫忙阿~~感激! -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.126.123.103

09/15 23:11, , 1F
從file名字來看, 感覺就是用到動態配置的地方有問題,
09/15 23:11, 1F

09/15 23:12, , 2F
new的地方, 該delete的地方, 指標/array操作的地方都檢
09/15 23:12, 2F

09/15 23:12, , 3F
查看看吧; 另一個猜測是如果總是在結束有問題, 要嘛結
09/15 23:12, 3F

09/15 23:13, , 4F
束前delete出了狀況, 要嘛也許有memory leak的情況發生.
09/15 23:13, 4F

09/15 23:13, , 5F
如果懂得用memory usage檢查的tool的話也可以試試@_@"
09/15 23:13, 5F

09/15 23:21, , 6F
這個部分有檢查了!!所以在呼叫的fun我直接把code拿掉讓他
09/15 23:21, 6F

09/15 23:22, , 7F
印出!!也檢查大大說的部分所以都先拿掉了!!
09/15 23:22, 7F

09/15 23:23, , 8F
所以目前用簡單的方式來測試可是還是有錯誤!!
09/15 23:23, 8F

09/17 09:27, , 9F
DLL與EXE檔都是debug或是全release嗎?
09/17 09:27, 9F

09/19 23:47, , 10F
都有試!他預設是debug我也有改成release跑過
09/19 23:47, 10F
文章代碼(AID): #1CaD4oiX (C_and_CPP)
文章代碼(AID): #1CaD4oiX (C_and_CPP)