Re: Euphoria DLLs

new topic     » goto parent     » topic index » view thread      » older message » newer message

I wrote:

[...]
> I'll do some testing this weekend with the Public Domain translator.
[...]

I made a DLL and a wrapper for it (Eu 2.4 Beta on Windows 98):

------------------------------------------------------------------>8---
file 'the.ew'
-----==---------------------------------------------------------==-----
-- I compiled this file to a DLL, using the Borland C++ Compiler 5.5

global procedure test_1 (integer fn, integer pntr)
   printf(fn, "procedure test_1: %d\n", {pntr})
end procedure

global procedure test_2 (integer fn, integer pntr)
   atom p
   p = 0.0 + pntr
   printf(fn, "procedure test_2: %d\n", {pntr})
end procedure

type dword (object x)
   -- This is for testing another idea.
   -- Using a user defined type for a parameter, that must be converted
   -- to an atom, would improve the readability of the code.
   return integer(x)
end type

global procedure test_3 (integer fn, dword pntr)
   atom p
   p = 0.0 + pntr
   printf(fn, "procedure test_3: %d\n", {pntr})
end procedure
------------------------------------------------------------------>8---


------------------------------------------------------------------>8---
file 'call_dll.exw'
-----==---------------------------------------------------------==-----
include dll.e

constant STDOUT = 1
atom dll, addr
integer test_1, test_2, test_3

dll = open_dll("the.dll")
test_1 = define_c_proc(dll, "test_1", {C_INT, C_UINT})
test_2 = define_c_proc(dll, "test_2", {C_INT, C_UINT})
test_3 = define_c_proc(dll, "test_3", {C_INT, C_UINT})

-- All 3 procedures will run OK:
addr = power(2,31) - 1
c_proc(test_1, {STDOUT, addr})
c_proc(test_2, {STDOUT, addr})
c_proc(test_3, {STDOUT, addr})

-- All 3 procedures will crash with the error message
-- "A machine-level exception occurred during execution of this statement":
addr = power(2,31)
c_proc(test_1, {STDOUT, addr})
c_proc(test_2, {STDOUT, addr})
c_proc(test_3, {STDOUT, addr})
------------------------------------------------------------------>8---


Using  addr = power(2,31) - 1  was OK,
using  addr = power(2,31)      caused a crash in all three cases.

If I didn't make a mistake somewhere in this test, it looks as if even
the trick in procedure test_2() doesn't work.

Best regards,
   Juergen

-- 
 /"\  ASCII ribbon campain  |
 \ /  against HTML in       |  Money is the root of all evil.
  X   e-mail and news,      |  Send 20 Dollars for more info.
 / \  and unneeded MIME     |

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu