ctypes with Compaq Visual Fortran 6.6B *.dll (Windows XP), passing of integer and real values
Duncan Booth
duncan.booth at invalid.invalid
Thu Jan 29 08:44:45 EST 2009
alex <alecla at bluewin.ch> wrote:
> Jon
> Thank you for your answer. I tried it with no success.
>
> However I tried with
> tst=cdll.LoadLibrary("f:\\scratch\\test2\\footst.dll") instead of
> tst=windll.LoadLibrary("f:\\scratch\\test2\\footst.dll")
>
> and it runs now with no error message, I can't figure for now why, but
> it's great! This is motivating for going ahead.
>
cdll is for importing functions which use the cdecl calling convention
where the caller must clean up the stack.
windll is for functions that use the stdcall calling convention: the
function that is called is responsible for cleaning up the stack.
If you were using windll when you should have been using cdll then ctypes
will have been expecting the library to clean up the stack, and the library
will have been expecting the caller to do the cleanup, so nobody cleaned up
the stack.
The error message was telling you that ctypes pushed 4 bytes of argument
onto the stack which weren't popped off by the caller. If you had been
using the correct calling convention that would have indicated you had
passed too many arguments, but as you were using the wrong calling
convention the message was a bit unclear.
--
Duncan Booth http://kupuguy.blogspot.com
More information about the Python-list
mailing list