我有一个用 C 语言编写的 dll 导出这个函数:
typedef struct testResult_t {
int testId;
int TT;
double fB;
double mD;
double mDL;
int nS;
int nL;
} TestResult;
TestResult __stdcall dummyTest(){
TestResult a = {0};
a.testId = 3;
return a;
};
我以这种方式从python调用函数:
class TestResult(Structure):
_fields_ = [
("testId", c_int),
("TT", c_int),
("fB", c_double),
("mD", c_double),
("mDL", c_double),
("nS", c_int),
("nL", c_int)
]
astdll.dummyTest.restype = TestResult
result = astdll.dummyTest()
print "Test ID: %d" % (result.testId)
执行脚本时出现此错误:
Traceback (most recent call last):
File "ast.py", line 330, in <module>
main()
File "ast.py", line 174, in main
result = astdll.dummyTest()
File "_ctypes/callproc.c", line 941, in GetResult
TypeError: an integer is required
任何想法有什么问题?