import "C"
func f() {
var vGo int
var vC C.int
// fails to compile with error
// cannot use &vGo (type *int) as type *C.int in argument to...
C.c_function(&vGo)
// compiles just fine:
C.c_function(&vC)
}我用CGO_ENABLED=1 GOARCH=arm编译..。
在这种情况下,int和C.int类型有什么不同?
在GO中,我在哪里可以找到关于C类型的其他信息?
发布于 2016-04-07 16:54:43
这两种类型有什么区别?那得看情况。如果使用64位,Go int将为64位,而C将为32位。如果你在32位,没有真正的区别。
在Go中,我在哪里可以找到关于C类型的其他信息?查看C文档,正如注释中提到的,Go中不允许隐式数字类型转换,因此需要进行转换。
https://stackoverflow.com/questions/36482444
复制相似问题