Hi,

What's the best way to declare an external C function that takes a function
pointer?  I want to pass a Chapel implemented function or an externally
implemented function.  I've done some research and experiments and haven't
found a good solution yet.

I originally (and naively) began with something like this in the Chapel
module:

proc ev_io_init_fn(ref loop: ev_loop_t, ref io: ev_io_t, x: c_int);
extern proc ev_io_init(ref io: ev_io_t, ref fn: ev_io_init_fn, fd: ev_fd_t,
events: ev_events_t);

and then in chpl:

export proc accept_cb(ref loop: ev_loop_t, ref watcher: ev_io_t, revents:
c_int) {
// do work
}

ev_io_init(w_accept, accept_cb, sd, EV_READ);

but this (and similar approaches) will produce a compilation error akin to:

chapel/chpl_tcp_server.chpl:38: error: unresolved call
'ev_io_init(c_ptr(ev_io_t),
chpl__fcf_type__ref_ev_loop_t__ref_ev_io_t_int32_t_void, int(32), int(32))'
[functionResolution.cpp:2448]
chapel/LibEv.chpl:75: note: candidates are: ev_io_init(io: c_ptr(ev_io_t),
ref fn: ev_io_init_fn, fd: ev_fd_t, events: ev_events_t) [128267]
[functionResolution.cpp:2463]

Thanks!
Brian
------------------------------------------------------------------------------
BPM Camp - Free Virtual Workshop May 6th at 10am PDT/1PM EDT
Develop your own process in accordance with the BPMN 2 standard
Learn Process modeling best practices with Bonita BPM through live exercises
http://www.bonitasoft.com/be-part-of-it/events/bpm-camp-virtual- event?utm_
source=Sourceforge_BPM_Camp_5_6_15&utm_medium=email&utm_campaign=VA_SF
_______________________________________________
Chapel-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/chapel-developers

Reply via email to