头文件:
#include <stdio.h>
import "C"
path := C.CString("/home/yanhao/1.txt")
C.printf("%s\n", path)
go run 1.go的结果:unexpected type: ...
>The message is confusing, until you realize that the ... is the variadic portion of a C function. You can't use C variadic >functions directly from Go, so you'll have to write a small wrapper in C to call
http://stackoverflow.com/questions/26852407/unexpected-type-with-cgo-in-go
package main
/*
#include <stdio.h>
void myprintf(char *s) {
printf("%s\n", s);
}
*/
import "C"
func main() {
path := C.CString("/home/yanhao/1.txt")
C.myprintf(path)
}
#1