[問題] C++的DLL回傳structre ref問題

看板C_and_CPP (C/C++)作者時間10年前 (2015/07/01 22:13), 編輯推噓0(0013)
留言13則, 4人參與, 最新討論串1/1
開發平台(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

07/02 01:10, , 1F
如果是用return就ok,用reference就回出錯
07/02 01:10, 1F

07/02 04:58, , 2F

07/02 04:59, , 3F
1. .c 第三個參數改成 Toutputs *, &str_outputs
07/02 04:59, 3F

07/02 04:59, , 4F
2. 不保證行為
07/02 04:59, 4F

07/02 04:59, , 5F
3. 參考 Roger Pate 的回答, 寫個 wrapper
07/02 04:59, 5F

07/02 08:53, , 6F
請問第一點在C加1上Toutputs *, &str_outputs會無法
07/02 08:53, 6F

07/02 08:54, , 7F
compiler
07/02 08:54, 7F

07/02 09:06, , 8F
第三點wrapper可否麻煩說明一下,謝謝~
07/02 09:06, 8F

07/02 12:42, , 9F
不論如何,你的 lpfnDllFunc 第三個參數就跟實際不同了。
07/02 12:42, 9F

07/02 12:43, , 10F
GetProcAddress 只是去輸出表找函數名,不會幫忙檢查這些
07/02 12:43, 10F

07/02 14:07, , 11F
請問第三個參數要如何定義及使用,感謝
07/02 14:07, 11F

07/02 22:25, , 12F
AAA是錯的...
07/02 22:25, 12F

07/02 22:26, , 13F
AAA應該要跟DLL內的簽名相同, 只是改成func ptr
07/02 22:26, 13F
文章代碼(AID): #1La_MOzt (C_and_CPP)
文章代碼(AID): #1La_MOzt (C_and_CPP)