Open gopherbot opened 10 years ago
At least since 2.95, GCC has supported the "unused" attribute to suppress warnings about unused variables. I've prepared https://golang.org/cl/121550043/ to make use of this in cgo. It also looks like -Werror=unused-variable has been supported since GCC 4.2, so it should be available on OS X and BSD too. Though even if we wanted to support an old-timey platform using an older GCC, we could just add an appropriate "// +build !openbsd,vax" line to issue8420.go. snyh: Can you please confirm whether the above CL adequately addresses your needs?
Compiling this program
package main
// #cgo CFLAGS: -Werror=unused-variable
// void test(){}
import "C"
func main() {
C.test()
}
on mac gives me:
...go/src/tmp % go build
# tmp
./main.go:8:2: could not determine kind of name for C.test
@mdempsky should we fix this?
It's fine if someone wants to fix this, but it's not an important bug to fix.
disable c go on environment variable or CGO_ENABLED=0
by Snyh1010: