I want to return a C struct value from a Go function. Assuming ProcessX() and ProcessY() are go methods which return integers (uint8 values):
package main
/*
struct Point {
char x;
char y;
};
*/
import "C"
//export CreatePoint
func CreatePoint(x uint8, y uint8) C.Point {
xVal := ProcessX(x);
yVal := ProcessY(y);
return C.Point {x: xVal, y: yVal}
}
func main() {}
But this results in a build error: ".\main.go:13:36: could not determine kind of name for C.Point"
Edit:
Using go build -ldflags "-s -w" -buildmode=c-shared -o mylibc.dll .\main.go to compile in Windows 10 through mingw
Edit-2:
I have removed the empty line between the "C" import and the preceeding preamble, but couldn't avoid the error. The code is now like:
/*
struct Point {
char x;
char y;
};
*/
import "C"