Re: [ctypes-users] Procedure called with not enough arguments (4bytesmissing) or wrong calling conv
Brought to you by:
theller
|
From: Victor B. <cty...@vi...> - 2009-12-14 16:31:32
|
On Sun, Dec 13, 2009 at 11:55 PM, Victor Blomqvist <cty...@vi...> wrote: > > On Sun, Dec 13, 2009 at 10:11 PM, Mark Tolonen <met...@gm...<metolone%2B...@gm...>> wrote: >> >> > Thanks for your help, problem not solved but at least a little bit >> > forward: >> > When I try your code it does work fine compiled with cl, but get the same >> > error when compiled with gcc. And thanks to the printf I can see that the >> > error is created at the return statement: >> >> python cp.py >> > bb=(1.000000,2.000000,3. >> > 000000,4.000000) >> > v=(10.000000,12.000000) >> > Traceback (most recent call last): >> > File "cp.py", line 31, in <module> >> > r = cpBBWrapVect(bb,Vec2d(10,12)) >> > ValueError: Procedure called with not enough arguments (4 bytes missing) >> > or >> > wrong calling convention >> > >> > Apparently its something with return of Vec2d's (probably structs in >> > general), but I don't know what or how to fix it? >> > >> > The full c library uses c99 and is mainly developed on linux/mac, meaning >> > it >> > is a bit tricky to compile with visual studio/cl so the best and easiest >> > would be if it could be made to work with mingw / gcc to minimize the work >> > required to compile it. But I guess I will have to reconsider if I don't >> > get >> > it to work properly.. >> >> A possibility: passing and returning structures on the stack vs. with >> pointers is likely compiler dependent. If you have the option to re-write >> the function to avoid this that may fix the issue. >> >> -Mark > Yes, I changed the function to return a pointer instead and then it worked as expected (same thing with ints or other simple types). However, I don't think there's any chance to convince the author to change all returned structs to struct pointers instead, and while I can modify it myself it would be hard to maintain. > > But at least it feels like the problem is found, something with how gcc return structs vs how ctypes expect them. I thought that a dll was callable from different programs regardless of the compiler used. I wonder if there's a compiler option to change the behaviour to something ctypes can understand, or if its possible to set something in the wrapper python code.. > > /Victor > Forgot to reply to the list :) Sorry for the extra mail Mark. /Victor |