package main // void a(long *p) {} import "C"
import ( "unsafe" ) //go:noinline func b() { x := int64(0) C.a((*C.long)(unsafe.Pointer(&x))) // do something without x } func main() { b() } x should be considered unreachable after C.a . If x is something allocated on heap, do I need to use runtime.KeepAlive(x) to make sure x will not be garbage collected? -- 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. For more options, visit https://groups.google.com/d/optout.