I am trying to access my function in a dll and pass by value as integer in it. But I am getting a ValueError as:
Procedure probably called with too many arguments (4 bytes in excess)
My python .py script is as below:
func2.restype = c_int
func2.argtypes = [c_int]
func2(3)
...
My actual function in the dll is just a simple function like:
int DLLfun2(int argtest) { return argtest + 1; };
...
Looks like a simple problem, but I'm guessing I am missing out on something. Kindly help.
Cheers.
Looks weird because integer should be automatically cast, but try with a func2(c_int(3))
EDIT : According to the ctypes doc, this exception could be raised because of a wrong calling convention (cdecl instead of stdcall). But the function is still called (just a sort of warning :s)
Be sure of you declaration in your dll.
If you load your library with windll
, it must use stdcall calling convention, otherwise, use the cdll
module.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With