C Structure rebuild with ctypes

Georg nobody at nowhere.org
Sun Dec 20 07:50:31 EST 2009


Hi All,

I need to use a library written in C. The routine  "int func (int handle, 
int *numVars, char ***varNames, int **varTypes)"

expects a complex object:

" ... Variable names are structured as an array of *numVars pointers, each 
pointing to a char string containing a variable name, and *varNames is set 
to point to the first element of the array. Variable types are stored into a 
corresponding array of *numVars in elements, and *varTypes is set to point 
to the first element of the array."

I tried using ctypes but nothing worked, e.g. "varNames = (c_char_p(c_char * 
65) * NumberOfVariables)()"

Can anyboby help? How do I have to state the structure "array of pointers to 
char string"? How is a pointer to the first element of such an array defined 
using ctypes? How do I allocate enough space for the char the array points 
to?

Best regards

Georg 





More information about the Python-list mailing list