I am trying to understand how to pass string values between Python3 and cythonized C++ function. However I am unable to build the library with Cython.
In particular, I didn't understand how to declare the string return value and string parameter in the source.pyx
. With the int type it works correctly.
The error I get during build with clang is the following:
candidate function not viable: no known conversion from 'PyObject *' (aka '_object *') to 'char *' for 1st argument
My source.pyx
is the following:
cdef extern from "source.cpp":
cdef str fun(str param)
def pyfun(mystring):
return fun(mystring)
My source.cpp
is:
char * fun(char *string) {
return string;
}