Is there a reason why Python's ctypes.CDLL cannot automatically generate restype and argtypes from C header files?

前端 未结 1 964
有刺的猬
有刺的猬 2021-02-05 10:31

For example, it would be nice to be able to do this:

from ctypes import CDLL
mylib = CDLL(\'/my/path/mylib.so\',header=\'/some/path/mylib.h\')

1条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-02-05 11:26

    I asked myself the same question and before I traveled down that road too far, I ran into ctypesgen:

    http://code.google.com/p/ctypesgen/

    It will handle all of this for you, although you will need to do a little learning up front. We use ctypesgen to generate one version of the Python bindings for the Subversion bindings. It works very well.

    0 讨论(0)
提交回复
热议问题