go-cshared-examples icon indicating copy to clipboard operation
go-cshared-examples copied to clipboard

how to use `GoInterface` struct in CGO?

Open idevz opened this issue 4 years ago • 1 comments

like the code below:

t.go
//export testFunc
func testFunc() (a interface{}) {
 a = 100
 return
}
t.h
typedef struct { void *t; void *v; } GoInterface;
// ...
extern GoInterface testFunc();

we export a function through CGO like extern GoInterface testFunc();, how to call this from C or Lua or others? how to initialization and using a GoInterface in C, or in the Luajit FFI context?

idevz avatar Feb 25 '20 06:02 idevz

Hello @idevz, we are looking to do the same, did you eventually find a way?

andreapicaro avatar May 17 '22 07:05 andreapicaro