Re: c_func in Eu 4.1 Beta (Windows)
- Posted by mattlewis (admin) Mar 19, 2014
- 1473 views
Ah...this is a calling convention problem. The dll is expecting cdecl (the default when you write C code), but the way it's imported in the code, you end up calling with stdcall (a win32 aberration). Try changing to "+sum"...
Thanks Matt, that fixes the issue for mylib.ex and my old program! This was starting to drive me a little crazy...
This problem has driven me *a lot* crazy over the years. It will be one of the great benefits of moving away from 32-bit Windows.
Speaking of which, now might be a good time for a certain someone to chime in and explain why this problem doesn't happen on 64bit windoze.
I'm not sure who you're referring to, but I can answer it even if you didn't mean me. There is only one calling convention on 64-bit windows. The basic problem was that x86 has very few registers, so you mostly have to pass parameters via the stack. x86-64 has a lot more registers, though the win64 calling convention doesn't use the registers as efficiently in its calling convention as the AMD64 spec calls out, and which other platforms use. Still, it's an improvement, and I think that MS had enough of their own headaches with dealing with the various calling conventions (their C++ compiler used its own where the *this* parameter gets passed in a register...Watcom had its own convention where some params got passed via register...etc).
Matt