我在使用ctypes从应该返回字符串的C ++库(用extern C包装)中调用函数时遇到问题。我很确定我已经为ctypes接口正确设置了我的argtypes和restype,该函数应该返回一个字符串,但是无论我返回的结果是什么,都只能得到一个空字符串。C ++代码:const char* disasmC_PEProgram_getSections(PEProgram *p) { return p->getSections().c_str();}Python代码:lib.disasmC_PEProgram_getSections.argtypes = [ctypes.c_void_p]lib.disasmC_PEProgram_getSections.restype = ctypes.c_char_presultStr = lib.disasmC_PEProgram_getSections(self.peProgram_p)# Displays empty string for resultStr!print "Result: %s" % (resultStr,)
添加回答
举报
0/150
提交
取消