On 19 ago, 14:44, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > Hi, > > can anybody with ctypes experience tell me, how to handle a C function > that returns an unsigned char*? Obviously it is not a restype of > c_char_p.
Being signed or unsigned is not important here. But you have to disambiguate "returns an unsigned char*" - the function returns a string of bytes (unsigned char), null- terminated. - the function returns a pointer to a single byte. In the first case, use a plain c_char_p - the individual "chars" are already unsigned in Python (that is, ord(xxx[i]) is always positive) In the second case, first define the pointer type: c_ubyte_p = POINTER(c_ubyte) your_function.restype = c_ubyte_p -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list