*I meant to say this error * # command-line-arguments duplicate symbol _parse in: $WORK/command-line-arguments/_obj/_cgo_export.o $WORK/command-line-arguments/_obj/one.cgo2.o ld: 1 duplicate symbol for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)
On Monday, December 18, 2017 at 10:03:47 PM UTC-5, rou...@gmail.com wrote: > > Hey guys, > > I want to write a c wrapper around a go code that has a callback > > func SomeGoComputation(address string, callback func(string,int)) { > _, err = // do some computation with address, maybe go over the > network > if (err != nil) { > callback(err.Error(), 0) > } > // I mean you get the gist > callback("",1) > } > > I've having trouble writing the callback signature which in c would be > void(*c_callback)(*char, int) > > //export Ccomputation > func Ccomputation(address *C.char, // how to write that callback) { > SomeGoComputation(C.GoString(address), func(errString string, code int > ){ > //passing the go callback values to the c callback wrapper > e := C.CString(errString) > c := C.int(code) > c_callback(e, c) > // then free both e and c via unsafe pointer > }) > } > > > I look around and some (articles or not related answer from go posts) say > to use an interface, so I did try `(C.char*, C.int)interface {}` but I > did get an error missing , at line where the callback was declared in the > wrapper. > > Any ideas, all advice are welcome thanks .. :) > -- 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.