Trundle <andy-pyt...@hammerhartes.de> added the comment: You are using `CFUNCTYPE` wrong. `CFUNCTYPE` returns a type which will take a *Python function* (or an address of a function as integer). You provide `lib.get_message` as Python function, which is a wrapper object for the C function. By default, ctypes assumes an int as return type for C functions. On your platform, the size of an int is not the same as the size of a pointer. Therefore, the return value is truncated. You call the CFUNCTION which then calls `lib.get_message` which returns the truncated pointer as integer and then ctypes tries to make a `c_char_p` out of the integer which segfaults because it's truncated.
I think what you are really looking for is ``lib.get_message.restype = c_char_p``. ---------- nosy: +Trundle _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue7160> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com