mirror of
https://github.com/golang/go
synced 2024-11-19 01:54:39 -07:00
05c67e95c4
We now have pretty good support for users of cgo packages. Add tests. Closes golang/go#35720. Change-Id: Icdc596038bc6fca1c08eacd199def12264cf512d Reviewed-on: https://go-review.googlesource.com/c/tools/+/208503 Run-TryBot: Heschi Kreinick <heschi@google.com> Reviewed-by: Rebecca Stambler <rstambler@golang.org>
27 lines
374 B
Go
27 lines
374 B
Go
package cgo
|
|
|
|
/*
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
|
|
void myprint(char* s) {
|
|
printf("%s\n", s);
|
|
}
|
|
*/
|
|
import "C"
|
|
|
|
import "fmt"
|
|
|
|
import "unsafe"
|
|
|
|
func Example() { //@mark(funccgoexample, "Example"),item(funccgoexample, "Example", "func()", "func")
|
|
fmt.Println()
|
|
cs := C.CString("Hello from stdio\n")
|
|
C.myprint(cs)
|
|
C.free(unsafe.Pointer(cs))
|
|
}
|
|
|
|
func _() {
|
|
Example()
|
|
}
|