gcc -fPIC -shared bob_hash.c -o bob_hash.so //把bob_hash.c文件编译成动态库
函数定义:
int hash_string(void *tmpstr)
python:
>>> from ctypes import CDLL,c_int,c_void_p
>>> bob_hash = CDLL('/home/gby/workspace/bob_hash.so')
>>> hash_string = bob_hash.hash_string
>>> hash_string.argtypes = [c_void_p]
>>> hash_string.restype = c_int
>>> a = hash_string('234')
>>> print a
124