#124

How to handle callback functions

OpenTheFern2opened 4y ago

What's the recommended way to dealing with callback funcs, any examples of current conversions doing this?


LIB_EXPORT int32_t plc_tag_create_ex(const char *attrib_str, void (*tag_callback_func)(int32_t tag_id, int event, int status, void *userdata), 

Activity

2
l0rem1psum3y ago

With the current Go standard library supporting things like cgo.Handle, it is rather simple now to create C callback to Go functions and vice versa (see: https://github.com/golang/go/wiki/cgo#calling-go-functions-from-c).

Is there any plan to add better support for callbacks in the future? @xlab

TheFern23y ago

With the current Go standard library supporting things like cgo.Handle, it is rather simple now to create C callback to Go functions and vice versa (see: https://github.com/golang/go/wiki/cgo#calling-go-functions-from-c).

Is there any plan to add better support for callbacks in the future? @xlab

Dunno if you already know, but I thought to share anyway, this is how I did callbacks on a project. https://github.com/libplctag/goplctag