func main() { var a, b int = 1, 2 r := C.sum(C.int(a), C.int(b)) // C 언어 함수 sum 호출 fmt.Println(r) // 3 C.hello() // Hello, world! }
func main() { r := C.rand() fmt.Println(r) var a, b int = 10, 20 r = C.sum(C.int(a), C.int(b)) fmt.Println(r) r = C.sum(C.int(20), C.int(30)) fmt.Println(r) C.hello() }
func main() { Seed(1000) fmt.Println(int(C.random())) time.Sleep(time.Duration(1) * time.Second) fmt.Println(int(C.random())) fmt.Println("getpid:", int(C.getpid())) C.puts(C.CString("call C puts")) Hello("call C's go wrapper func") C.hello(C.CString("call C hello func")) }
func Hello(s string) { cs := C.CString(s) C.hello(cs) }
func main() { C.hello() }
func Hello() { C.hello() }
func main() { C.hello(C.CString("John Smith")) }
func Hello() int { return int(C.hello()) }