I'm trying to call a Go function from C using CGo. The function shall
accept a char** argument.
The following code exemplifies what I'm trying to do:
package main
//
// typedef void (*Callback)(int argnum, char **args );
// void CallMe( Callback f ) {
// char *args[2] = { "Ciao", "mondo" };
// f(2, args);
//
//}
import "C"
import "unsafe"
func GoCallback( argnum C.int, args unsafe.Pointer ) {
// Convert args and do stuff
}
func main() {
C.CallMe(GoCallback)
}
I get the following error :
*Cannot use GoCallback (type func(_Ctype_int, unsafe.Pointer)) as type
*[0]byte in function argument*
How comes a C function pointer becomes a *[0]byte ( which should translate
to "pointer to a zero-length array of bytes" ) ??
P.S : Doing C.CallMe(C.Callback(GoCallback)) gives the following error,
which is less puzzling but does not explain much:
*cannot convert GoCallback (type func(_Ctype_int, unsafe.Pointer)) to type
C.Callback *
Thanks in advance for any help
Ciao
---
FB
--
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.