structs-simple/main.go
package main // #cgo CFLAGS: -g -Wall /* struct operands { int a; int b; }; */ import "C" import ( "fmt" ) type operands struct { a int32 b int32 } func CPlus(ops C.struct_operands) C.int { return C.int(Plus( operands{ a: int32(ops.a), b: int32(ops.b), }, )) } func Plus(ops operands) int32 { return ops.a + ops.b; } func main() { cops := C.struct_operands{a: 1, b: 2} fmt.Printf("%+v\n", CPlus(cops)) }