I am experimenting with ctypes and I found something that baffled me. I have a .so file that exports this function:
void hello(int a) {
printf("hello, a=%d", a);
}
I call it from Python, but I put a parameter of the wrong type to see what happens:
mydll = ctypes.CDLL("libhello.so")
mydll.hello('this is string')
This does not cause an error and just prints hello, a=-1219868708. But if I pass a double instead of - mydll.hello(1.0), then it throws an exception:
ctypes.ArgumentError: argument 1:: Don't know how to convert parameter 1
It seems strange to me that exported C functions usually do not have information about their signature (unlike C ++ functions), just the name of the function and possibly the total number of parameter bytes.
, , , , ctypes , , 2 - mydll.hello('string1', 'string2'), ; hello, a=-1223698284.
, . ctypes, , a double , , 2 ?