On Mon, Dec 23, 2024 at 8:29 AM 'Red' via golang-nuts <golang-nuts@googlegroups.com> wrote: > > I need to use CGO to call a C function in a Go program, where the parameter > type is a void pointer. Now I need to pass a struct to the C function, and > the struct contains a channel. Additionally, I have a Go callback function > that the C function will call, using the data from this struct. The problem > is that when I try to access this struct in the Go callback function, I can't > retrieve the data. Is this because it is not supported to pass a channel type > to C? > > The documentation I referred to: > > https://pkg.go.dev/runtime/cgo#Handle > https://groups.google.com/g/golang-nuts/c/PLSIN5jmzpM/m/L9bYGl3oAQAJ
You can pass a channel to C code using a cgo.Handle. I don't know what you mean when you say "I can't retrieve the data." Can you show a small self-contained example that demonstrates the problem? Ian -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion visit https://groups.google.com/d/msgid/golang-nuts/CAOyqgcV%3DrHRtwgMS-Og_wgWjn_i8aQ4fTdLE8iVSL8Fu9wYo%2Bw%40mail.gmail.com.