[pypy-dev] How to convert python string to C char*?
Yicong Huang
hengha.mao at gmail.com
Thu May 14 05:02:02 CEST 2015
We had a python function that return a string value. The function will
callback in C code.
The below is an example of the code:
@ffi.callback("char *(char *, char *)")
def strconcat(x, y):
x1 = ffi.string(x)
y1 = ffi.string(y)
print x1 + y1
return x1 + y1
The error messages are:
Trying to convert the result back to C:
TypeError: initializer for ctype 'char *' must be a cdata pointer, not str
How could we convert the return python string value to C char*?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/pypy-dev/attachments/20150514/63cf7c20/attachment.html>
More information about the pypy-dev
mailing list