mirror of
https://github.com/golang/go
synced 2024-11-19 06:34:42 -07:00
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()
|
||
|
}
|