bart2
June 10, 2022, 7:34am
1
Hi, how to declare function (GIOFunc) which is specified as following:
pub type GIOFunc =
Option<unsafe extern "C" fn(*mut GIOChannel, GIOCondition, gpointer) -> gboolean>;
And it is used here:
pub fn g_io_add_watch(
channel: *mut GIOChannel,
condition: GIOCondition,
func: GIOFunc,//here, how to define that function?
user_data: gpointer,
) -> c_uint;
You literally go:
unsafe extern "C" fn cback(chan: *mut GIOChannel, cond: GIOCondition, ptr: gpointer) -> gboolean {
// Code here
}
bart2
June 10, 2022, 7:43am
3
Thanks, I seem to have a mental block. When I code C/C++ all's good. When I learn rust I seem to be doing OK.
That is not the case when I start using unsafe rust.
Thanks again.
system
Closed
September 8, 2022, 7:43am
4
This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.