3

I am using ctypes in Python to access functions from a shared C library. One of the parameters for one of the functions requires an empty array of the type char to write error messages into. The code for the array in C++ is simple;

char messageBuffer[256];

I would like to write the equivalent in Python so that I can pass an array containing the correct data type to the function. I've tried simply creating and array in Python of length 256, but I get the error message;

mydll.TLBP2_error_message(m_handle, errorCode, messageBuffer)

ArgumentError: argument 3: <class 'TypeError'>: Don't know how to convert parameter 3

Any help is appreciated.

2
  • Don't know anything about ctyes but does this help? Not sure if a duplicate. Commented Jul 9, 2019 at 16:46
  • Please format your question according to [SO]: How to create a Minimal, Complete, and Verifiable example (mcve). Add the C function header, and the Python code that uses it (not only the call, but also loading the lib, and preparing the stuff for the call). Commented Jul 9, 2019 at 17:05

0

Your Answer

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.