I recently put up an article on EiffelRoom for doing C++ callbacks but
the C++ example doesn't actually work.
http://www.eiffelroom.org/article/c_c_calls_and_callbacks I can't
tell if this is a compiler bug or a mistake I'm making. The C version
at the top works, but the C++ version at the bottom doesn't despite
being virtually identical. When the application
is run and c_do_callback is called, the procedure does nothing. It
doesn't crash, it's as if the procedure is never run.
The code in question is:
c_do_callback (obj: POINTER) is
external
"C++ inline use %"application.h%""
alias
"((test_class *) ($obj))->c_do_callback();"
end
void test_class::c_do_callback ()
{
((void (*) (EIF_REFERENCE)) routine) (eif_access (obj));
}
And the routine pointer is pointing to:
inside is
local
current_addr: POINTER
do
current_addr := $Current
io.put_string ("We're inside at address: " +
current_addr.to_integer_32.out)
io.put_new_line
end
I tried editing test_class::c_do_callback to be:
void test_class::c_do_callback ()
{
EIF_EIFFEL_ENTER;
((void (*) (EIF_REFERENCE)) routine) (eif_access (obj));
EIF_EIFFEL_EXIT;
}
however this didn't help. I'm not even sure if these were necessary
since the call originated in Eiffel.
Has anyone else run in to this issue?
------------------------------------
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/eiffel_software/<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/eiffel_software/join (Yahoo! ID required)
<*> To change settings via email:
mailto:
eiffel_software-digest@...
mailto:
eiffel_software-fullfeatured@...
<*> To unsubscribe from this group, send an email to:
eiffel_software-unsubscribe@...
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/