From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.



當使用 Call Library Funtion 的時候,使用 C 或是 Standard Calling Conventions 有什麼差別?



主要軟體:
主要軟體版本: 6.0
主要軟體修正版本: N/A
次要軟體: N/A

問題: 當我在 LabVIEW 中設定 Call Library node 的時候,其中有一個 calling convention (呼叫協定) 選項是使用 C 或著是 stdcall (WINAPI) ,我該使用哪一個以及兩者有什麼差別?

解答: 您正在呼叫的動態連結 (DLL) 會決定需要使用哪個呼叫協定 (calling convention) , DLL 可以執行其中任何一個協定,但當您的DLL執行時選擇了錯誤的協定,您可以能會收到 error 或導致程式 crash 。

當使用子程式時,呼叫協定一般來講代表參數會怎麼被處理。當使用 C 的呼叫協定時,呼叫的程式 (caller) 要負責清空記憶體中的堆疊 (stack);但當使用標準 (stdcall) 的呼叫協定時,是被呼叫 (called) 的函數要複雜清空堆疊。如果呼叫的程式 (LabVIEW) 和被呼叫的 DLL 函數沒有使用同樣的呼叫協定時,他們可能兩者都會去清空記憶體中的堆疊,或是兩者都不會。這兩種情況都會導致 LabVIEW crash 在呼叫完函數回到主程式的時候。這個呼叫協定的選項可以在 Call Library Function node 視窗的右下角找到。



相關連結:
KB 59KB14WI: I Can Use My DLL in LabVIEW 2009 but in LabVIEW 2010 it Crashes

附加檔案:





報告日期: 09/20/2002
最後更新: 05/17/2016
文件偏號: 2PJG4QQG