1 回答

TA貢獻(xiàn)1836條經(jīng)驗(yàn) 獲得超3個(gè)贊
多虧了@talonmies注釋的指示,我發(fā)現(xiàn)至少在簡(jiǎn)單的情況下,我可以通過(guò)定義一個(gè)看起來(lái)像這樣的頭文件來(lái)調(diào)用cl.exe和nvcc.exe從cgo創(chuàng)建的dll:
#ifdef __cplusplus
extern "C" { // only need to export C interface if
// used by C++ source code
#endif
__declspec(dllexport) int testfunc();
#ifdef __cplusplus
}
#endif
此代碼是引用以下兩篇 MSDN 文章創(chuàng)建的:https://docs.microsoft.com/en-us/cpp/build/exporting-cpp-functions-for-use-in-c-language-executables?view=msvc-160
https://docs.microsoft.com/en-us/cpp/build/exporting-c-functions-for-use-in-c-or-cpp-language-executables?view=msvc-160
- 1 回答
- 0 關(guān)注
- 194 瀏覽
添加回答
舉報(bào)