Assuming I have a C function with a list of arguments of variable length:
int some_func(int arg1 , ... );
Is it possible (just?) To call this function from python using ctypes?
Update:
Realized cedric offer and working like a charm:
libc = ctypes.CDLL( "/lib64/libc.so.6" , ctypes.RTLD_GLOBAL ) printf = getattr( libc , "printf") printf("String1:%s int:%d String2:%s double:%lg\n" , "Hello" , 10 , "World" , ctypes.c_double( 3.1415 ))
The ctypes.c_double () function is the only minor interference. So - it was all easier than me; however, I assume the fxxx option with va_args remains the same.
source share