Too many arguments in my function - Python

I am trying to access my function in dll and pass integer value through it. But I get a ValueError as:

Procedure probably called with too many arguments (4 bytes in excess) 

My python.py script looks like this:

 func2.restype = c_int func2.argtypes = [c_int] func2(3) 

...

My actual function in the dll is a simple function, for example:

 int DLLfun2(int argtest) { return argtest + 1; }; 

...

Looks like a simple problem, but I guess I'm missing something. Please help.

Greetings.

+6
source share
1 answer

It looks weird because an integer should be added automatically, but try using func2(c_int(3))

EDIT: According to ctypes doc , this exception may be caused by an incorrect call (cdecl instead of stdcall). But the function is still called (just a kind of warning: s)

Make sure you specify in your dll.

If you load the library using windll , it must use the stdcall calling convention, otherwise use the cdll module.

+3
source

Source: https://habr.com/ru/post/897305/


All Articles