开发者

Too many arguments in my function - Python

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 wi开发者_高级运维th 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜