作者jerelee ()
看板C_and_CPP
標題[問題] C++的DLL回傳structre ref問題
時間Wed Jul 1 22:13:37 2015
開發平台(Platform): (Ex: VC++, GCC, Linux, ...)
Eclipse
額外使用到的函數庫(Library Used): (Ex: OpenGL, ...)
sqlite3
問題(Question):
C++'s DLL 內設定回傳reference structure時會出現
str_output11.str_output0=1.0;//debug到這行,出錯exe己經停止運作
麻煩大家幫我看看,謝謝
餵入的資料(Input):
預期的正確結果(Expected Output):
可回傳reference structure
錯誤結果(Wrong Output):
出錯exe己經停止運作
程式碼(Code):請善用置底文網頁, 記得排版)
C++程式碼(DLL)
http://paste.plurk.com/show/2197276/
C程式碼(call C++'s DLL)
http://paste.plurk.com/show/2197281/
補充說明(Supplement):
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 122.116.5.201
※ 文章網址: https://www.ptt.cc/bbs/C_and_CPP/M.1435760024.A.F77.html
→ jerelee: 如果是用return就ok,用reference就回出錯 07/02 01:10
→ scwg: 1. .c 第三個參數改成 Toutputs *, &str_outputs 07/02 04:59
→ scwg: 2. 不保證行為 07/02 04:59
→ scwg: 3. 參考 Roger Pate 的回答, 寫個 wrapper 07/02 04:59
→ jerelee: 請問第一點在C加1上Toutputs *, &str_outputs會無法 07/02 08:53
→ jerelee: compiler 07/02 08:54
→ jerelee: 第三點wrapper可否麻煩說明一下,謝謝~ 07/02 09:06
→ firose: 不論如何,你的 lpfnDllFunc 第三個參數就跟實際不同了。 07/02 12:42
→ firose: GetProcAddress 只是去輸出表找函數名,不會幫忙檢查這些 07/02 12:43
→ jerelee: 請問第三個參數要如何定義及使用,感謝 07/02 14:07
→ WPC001: AAA是錯的... 07/02 22:25
→ WPC001: AAA應該要跟DLL內的簽名相同, 只是改成func ptr 07/02 22:26