Beispiel #1
0
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!
}
Beispiel #2
0
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()
}
Beispiel #3
0
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"))
}
Beispiel #4
0
func Hello(s string) {
	cs := C.CString(s)
	C.hello(cs)
}
Beispiel #5
0
func main() {
	C.hello()
}
Beispiel #6
0
func Hello() {
	C.hello()
}
Beispiel #7
0
func main() {
	C.hello(C.CString("John Smith"))
}
Beispiel #8
0
func Hello() int {
	return int(C.hello())
}