Re: Callback problem

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

>This sounds like the cdecl-stdcall problem.
>...
>There probably is a way to fix it by poking assembly.
>
>Karl Bochert


I did just that in Glue, my GLUT wrapper for Euphoria. In glue.e there is a 
function called cdecl_callback that takes a routine_id and a sequence of 
parameter sizes (in bytes). E.g. if you have a function foo that takes 3 
integer parameters, you'd do something like:

atom my_callback
my_callback = cdecl_callback(routine_id("foo"),{4,4,4,4})

Note that i passed 4 4's, this is intentionally. You see, there's a small 
problem: Since EIP is pushed on the stack after the parameters, you'll get 
the return address in the first parameter of your function. To get around 
this you must prepend a dummy argument to your function. I.e. if you had:

function foo(integer a,integer b,integer c)

You'd have to change it to:

function foo(integer dummy,integer a,integer b,integer b)

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

Search



Quick Links

User menu

Not signed in.

Misc Menu