You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to implement a Rust interface for libevent (because an external library I want to use depends on it).
Note that there is an example with working code, code that issues the compiler error and a diff between these two in this gist: https://gist.github.com/manuels/aaaf1ef5d8a072c19f11
When I define a C callback function for a libevent event:
extern "C"
fn printme(ev: *const c_int, flags: c_short, args: *const c_int) {
// using this as a libevent callback works just fine
println!("hello");
}
the code works fine. Note that args is a userdefined argument that will be used in the next step.
Relying on callbacks to be defined as "extern C" is a bit clumsy, so I'd like to define an "extern C" wrapper function that calls the rust callback function:
type watch_fd_callback_t = fn(*const c_int, c_short);
extern "C"
fn c_watch_fd_callback(ev:*const c_int, type_:c_short, cb: watch_fd_callback_t) {
// using this as a libevent callback crashes the compiler.
// probably because this "extern C" function indirectly
// calls the non "extern C" function printme() (==cb)
cb(ev, type_)
}
fn printme(ev: *const c_int, flags: i16) {
println!("hello");
}
So when I use the "extern C" wrapper callback c_watch_fd_callback() that calls the rust callback printme() the compiler crashes with this backtrace:
…ling-proc-macros-in-analysis-stats, r=Veykril
analysis-stats: respect `--disable-proc-macros` flag
I noticed that this flag wasn't being respected by `analysis-stats` when profiling proc macro expansion, so here's a small fix.
I want to implement a Rust interface for libevent (because an external library I want to use depends on it).
Note that there is an example with working code, code that issues the compiler error and a diff between these two in this gist:
https://gist.github.com/manuels/aaaf1ef5d8a072c19f11
When I define a C callback function for a libevent event:
the code works fine. Note that
args
is a userdefined argument that will be used in the next step.Relying on callbacks to be defined as "extern C" is a bit clumsy, so I'd like to define an "extern C" wrapper function that calls the rust callback function:
So when I use the "extern C" wrapper callback
c_watch_fd_callback()
that calls the rust callbackprintme()
the compiler crashes with this backtrace:I'm running
Linux 3.16-2-amd64 #1 SMP Debian 3.16.3-2 (2014-09-20) x86_64 GNU/Linux
withrustc 0.13.0-nightly (222ae8b9b 2014-10-18 00:47:22 +0000)
.The text was updated successfully, but these errors were encountered: