I have a DLL with a function of the following form:
void Foo ( int * i, char ** s )
{
if ( *i > (int)(strlen(date_string) + strlen(time_string) + 2) )
sprintf ( *s, "%s %s", time_string, date_string );
}
where
char date_string[] = { __DATE__ };
char time_string[] = { __TIME__ };
But adapting the method used here:
Python and ctypes: how to correctly pass "pointer-to-pointer" into DLL?
by using:
i = c_int(22)
s = POINTER(c_byte)()
Foo(byref(i),byref(s))
just results in the interpreter not producing any output. Does anyone know what I'm doing wrong?
s?create_string_buffer: docs.python.org/2/library/ctypes.html. That's what you should be using for passing a mutable**char.* ppMem = malloc( * pSize );s=create_string_buffer(22)? Using a variety of combinations ofbyrefandpointereither results in an write access violation, or a warning that I've passed too many arguments (8 bytes excess).s, i.e.byref(POINTER(c_char)(s)). This usesPOINTER(c_char)(s)to match a declaration ofFoo.argtypes = (POINTER(c_int), POINTER(POINTER(c_char))). Given the latter, usingpointer(s)instead would raise an exception because it creates a pointer to ac_chararray instead of to a singlec_char.