python函数指针 python ctypes 指针( 三 )


_fields_ = [("name", c_char * 20), ("age", c_int)]
if __name__ == "__main__":
lib = cdll.LoadLibrary("./libtest.so")
lib.test.restype = POINTER(StructPointer)
p = lib.test()
print "%s: %d" %(p.contents.name, p.contents.age)
最后运行结果:
[plain] view plain copy
[zcm@c_py #112]$make clean
rm -f *.o libtest.so
[zcm@c_py #113]$make
gcc -g -fPIC -shared -o libtest.so test.c
[zcm@c_py #114]$./call.py
Joe: 20
[zcm@c_py #115]$
python函数指针的介绍就聊到这里吧 , 感谢你花时间阅读本站内容,更多关于python ctypes 指针、python函数指针的信息别忘了在本站进行查找喔 。

推荐阅读