go调用c函数出错

yh_123 · 2015-08-19 08:40:31 · 2680 次点击

>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 

void myprintf(char *s) {
  printf("%s\n", s);
}
*/
import "C"

func main() {
  path := C.CString("/home/yanhao/1.txt")
  C.myprintf(path)
}
#1