I got a liba.so containing a function say_hi(),
char *say_hi()
{
return "hello, world";
}
In Python, I accessed liba.so via ctypes,
>>>liba = ctypes.CDLL("./liba.so")
>>>liba.say_hi()
16422018
How can I retrieve the string "hello, world" returned by liba.say_hi() in Python?
PS
Besides restype, any other way?
The docs of Python ctypes-modules offers type-casting functions. Eg. c_char_p:
So try this:
PS: It builds immutable strings. For mutable ones look at create_string_buffer
There are also some self-descriptive exameples on the page.