
__declspec(dllexport)extern "C"去除 Manglingextern "C"必须放在__declspec(dllexport)前面,不然__declspec(dllexport)会不生效// example.cpp ->example.dll
extern "C"
__declspec( dllexport )
int
triple( int i )
{
return 3 * i;
}triple
import ctypes
lib = ctypes.windll.LoadLibrary('example.dll')
print(lib.triple(3))3. 常见的问题function 'triple' not found,可以打开 lib 看看是不是没有这个函数extern "C",函数名会出现 mangling,例如?triple@@YAHH@Z,这样的函数需要用 ctypes 的 getattr 来找到函数func = getattr(lib, "?triple@@YAHH@Z")
你是否还在寻找稳定的海外服务器提供商?创新互联www.cdcxhl.cn海外机房具备T级流量清洗系统配攻击溯源,准确流量调度确保服务器高可用性,企业级服务器适合批量采购,新人活动首月15元起,快前往官网查看详情吧