1. c_func in Eu 4.1 Beta (Windows)

Everyone,

I just noticed today that some old code of mine no longer works in the new Eu 4.1 Beta (Revision Date: 2014-01-16 02:53:44, Id: 5783:d41527402a7a) when using c_func on Windows. As a sanity check, I ran the 'mylib.ex" example and it doesn't appear to work either. The program silently dies when trying to make the first c_func call. C_func works as expected on Linux and OSX. Anyone else noticed this?

Thanks,
Ira

new topic     » topic index » view message » categorize

2. Re: c_func in Eu 4.1 Beta (Windows)

Jerome said...

Everyone,

I just noticed today that some old code of mine no longer works in the new Eu 4.1 Beta (Revision Date: 2014-01-16 02:53:44, Id: 5783:d41527402a7a) when using c_func on Windows. As a sanity check, I ran the 'mylib.ex" example and it doesn't appear to work either. The program silently dies when trying to make the first c_func call. C_func works as expected on Linux and OSX. Anyone else noticed this?

I just pulled down to the tip of the default branch and did fresh builds of 64-bit Windows and Linux and the mylib demo works correctly for me (using WINE for the Windows version).

Matt

new topic     » goto parent     » topic index » view message » categorize

3. Re: c_func in Eu 4.1 Beta (Windows)

Jerome said...

Everyone,

I just noticed today that some old code of mine no longer works in the new Eu 4.1 Beta (Revision Date: 2014-01-16 02:53:44, Id: 5783:d41527402a7a) when using c_func on Windows. As a sanity check, I ran the 'mylib.ex" example and it doesn't appear to work either. The program silently dies when trying to make the first c_func call. C_func works as expected on Linux and OSX. Anyone else noticed this?

Thanks,
Ira

Hi

I didn't test it, but

integer sum 
... 
sum = define_c_func(mylib, "sum", {C_INT}, C_INT)  

I had bad experiences with using intergers as pointer to dll functions on Windows.

In WIn32 you have a 2Gig adressspace for user and the integer only could handle 1 Gig

maybe you give it a try with 'atom sum'

hope this helps

Andreas

new topic     » goto parent     » topic index » view message » categorize

4. Re: c_func in Eu 4.1 Beta (Windows)

andi49 said...
Jerome said...

Everyone,

I just noticed today that some old code of mine no longer works in the new Eu 4.1 Beta (Revision Date: 2014-01-16 02:53:44, Id: 5783:d41527402a7a) when using c_func on Windows. As a sanity check, I ran the 'mylib.ex" example and it doesn't appear to work either. The program silently dies when trying to make the first c_func call. C_func works as expected on Linux and OSX. Anyone else noticed this?

Thanks,
Ira

Hi

I didn't test it, but

integer sum 
... 
sum = define_c_func(mylib, "sum", {C_INT}, C_INT)  

I had bad experiences with using intergers as pointer to dll functions on Windows.

In WIn32 you have a 2Gig adressspace for user and the integer only could handle 1 Gig

maybe you give it a try with 'atom sum'

hope this helps

Andreas

Hmm. I think that's one area where a subtle difference may exist between WINE and native Windoze.

In general, it's not always a good idea to develop Windoze apps using WINE. (Understandably, though, it can be a lot more convenient - but one generally shouldn't say "It works fine on WINE, so it must work fine on native Windoze too.")

http://stackoverflow.com/questions/1237898/developing-windows-applications-on-linux

new topic     » goto parent     » topic index » view message » categorize

5. Re: c_func in Eu 4.1 Beta (Windows)

Well, I could be doing something silly here but I can't get c_func to work on 32-bit Windows for the latest Eu (the beta release and the latest tip do not work for me).

mattlewis said...

I just pulled down to the tip of the default branch and did fresh builds of 64-bit Windows and Linux and the mylib demo works correctly for me (using WINE for the Windows version).

Thanks Matt, the 64-bit Windows Eu does work as expected for me (native Windows 8).

andi49 said...

maybe you give it a try with 'atom sum'

Thanks for the tip but still no joy.

Can someone else check if "c_func" works using the 32-bit interpreter on Windows?

Thanks,
Ira

new topic     » goto parent     » topic index » view message » categorize

6. Re: c_func in Eu 4.1 Beta (Windows)

I have used 32 bit Euphoria 4.1 c_proc and c_func extensively in Windows 7. No problems whatsoever.

new topic     » goto parent     » topic index » view message » categorize

7. Re: c_func in Eu 4.1 Beta (Windows)

Jerome said...

Well, I could be doing something silly here but I can't get c_func to work on 32-bit Windows for the latest Eu (the beta release and the latest tip do not work for me).

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" in the define_c_func call and it should work. You probably have the same problem in your other code.

I believe that Watcom added its own cleanup code no matter the calling convention, so it could hide this problem, but we're not building with Watcom any more.

Matt

new topic     » goto parent     » topic index » view message » categorize

8. Re: c_func in Eu 4.1 Beta (Windows)

mattlewis said...

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

-Ira

new topic     » goto parent     » topic index » view message » categorize

9. Re: c_func in Eu 4.1 Beta (Windows)

Jerome said...
mattlewis said...

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.

Matt

new topic     » goto parent     » topic index » view message » categorize

10. Re: c_func in Eu 4.1 Beta (Windows)

mattlewis said...
Jerome said...
mattlewis said...

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.

Matt

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.

new topic     » goto parent     » topic index » view message » categorize

11. Re: c_func in Eu 4.1 Beta (Windows)

jimcbrown said...
mattlewis said...
Jerome said...
mattlewis said...

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

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu