慕盖茨4494581
新来这里。试图从 C 调用 go 函数但遇到了一些编译问题这是 go 脚本package main// #cgo CFLAGS: -Wno-error=implicit-function-declaration// #include <stdlib.h> // #include "wrapper.c"import "C"//import "unsafe"import "fmt"//import "time"//export dummyfunc dummy() int { fmt.Println("hi you"); return 0}func main() { C.testc()}这是包装纸#include <sys/types.h>#include <stdio.h>#include <errno.h>#include <string.h>extern int dummy();void testc(){ dummy();}运行时报错xyz@xyz-HP:~/learn/go$ go run reader.go # command-line-argumentsIn file included from $WORK/command-line-arguments/_obj/_cgo_export.c:2:0:reader.go:30:14: error: conflicting types for ‘dummy’In file included from reader.go:3:0, from $WORK/command-line-arguments/_obj/_cgo_export.c:2:./wrapper.c:6:12: note: previous declaration of ‘dummy’ was here/tmp/go-build528677551/command-line-arguments/_obj/_cgo_export.c:8:7: error: conflicting types for ‘dummy’In file included from reader.go:3:0, from $WORK/command-line-arguments/_obj/_cgo_export.c:2:./wrapper.c:6:12: note: previous declaration of ‘dummy’ was here