4

I tried loading C shared library .so in Python using ctypes.CDLL class (Linux). Here is the link to which tells what I did. As I see the documentation it says CDLL class assumes that function returns int types. I've a doubt here what if I need to return variable of type other than the int type from a function in C?. And to what extent we can use C functions in Python i mean what are the limits/restrictions on using C shared libraries and functions

Thanks in Advance

asked Jul 6, 2010 at 5:36

1 Answer 1

4

By default, it assumes int, but you can set restype to any of the supported types to override that. E.g., from the docs:

strchr.restype = c_char_p

This means that strchr returns a pointer to a char, which corresponds to a Python string (or None, for a NULL pointer).

answered Jul 6, 2010 at 5:42
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.