extern "C" _declspec(dllexport) double _stdcall add(double a, double b);//匯出一個函式
然后在另一邊動態加載dll
GetProcAddress("_add@16")匯出函式名稱從原始碼中的 add --> _add@16
我搜索了一下,這是stdcall呼叫約定的特點。
想請教一下:那么為什么這個呼叫約定要這么規定這一手呢?這么做有什么好處嗎(我相信如果沒有意義,不會多此一舉)?
謝謝大家了。
uj5u.com熱心網友回復:
關于 通過def檔案來指定名稱這點,我通過搜索已經知道了。但這并不能解決我的所訴的這個問題
uj5u.com熱心網友回復:
https://stackoverflow.com/questions/4550294/stdcall-name-mangling-using-extern-c-and-dllexport-vs-module-definitions-msvc剛剛終于找到有略微講解這個的說法了:
In stdcall calling convention, the callee removes the parameters from the stack. To make that safe, the exported name contains the number of bytes that the callee will remove from the stack.
大概說這個stdcall是內平堆疊,所以要加@number這個。說是要安全一點。怎么安全呢?誰會來參考這個@number呢?
uj5u.com熱心網友回復:
為了見名知意吧。并沒什么特別的約束。就像 你叫 千夢一生 , 我看到了會有點眼熟。 但如果你是一串數字,我可能永遠都不會記住你。
個人觀點。
另外,也許標準并沒有規定這個命名方式。 不太清楚。
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/171389.html
標籤:C++ 語言
