How can I convert data types from c to go and vice-versa?
如何将数据类型从c转换为go,反之亦然?
For example, I have a function that returns an array of integers:
例如,我有一个返回整数数组的函数:
char* Test()
{
char*msg = "Hello, Go";
return msg;
}
How can I convert it to slice or array?
如何将其转换为切片或数组?
--UPDATE--
--UPDATE--
In Go file, I can use C.GoString(C.Test())
to convert the return type to Go String. I'm looking for a complete doc for these functions.
在Go文件中,我可以使用C.GoString(C.Test())将返回类型转换为Go String。我正在寻找这些功能的完整文档。
1 个解决方案
#1
7
You should have a look at http://golang.org/cmd/cgo/ . Here's an example using it http://golang.org/misc/cgo/gmp/gmp.go
你应该看看http://golang.org/cmd/cgo/。这是一个使用它的例子http://golang.org/misc/cgo/gmp/gmp.go
#1
7
You should have a look at http://golang.org/cmd/cgo/ . Here's an example using it http://golang.org/misc/cgo/gmp/gmp.go
你应该看看http://golang.org/cmd/cgo/。这是一个使用它的例子http://golang.org/misc/cgo/gmp/gmp.go