Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 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.

like image 423
Neophile Avatar asked Sep 14 '11 09:09

Neophile


1 Answers

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.

like image 98
Cédric Julien Avatar answered Oct 04 '22 04:10

Cédric Julien