From: Russ Cox Date: Thu, 8 Mar 2012 03:40:32 +0000 (-0500) Subject: cmd/cgo: silence const warnings X-Git-Tag: weekly.2012-03-13~104 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=43d71e7d7d1ace38e6518335ff39b7848700b9ca;p=gostls13.git cmd/cgo: silence const warnings Fixes #3152. R=golang-dev, dsymonds, r CC=golang-dev https://golang.org/cl/5786047 --- diff --git a/src/cmd/cgo/out.go b/src/cmd/cgo/out.go index 4dc0f84549..d6447caff6 100644 --- a/src/cmd/cgo/out.go +++ b/src/cmd/cgo/out.go @@ -411,10 +411,20 @@ func (p *Package) writeOutputFunc(fgcc *os.File, n *Name) { } } fmt.Fprintf(fgcc, "%s(", n.C) - for i := range n.FuncType.Params { + for i, t := range n.FuncType.Params { if i > 0 { fmt.Fprintf(fgcc, ", ") } + // We know the type params are correct, because + // the Go equivalents had good type params. + // However, our version of the type omits the magic + // words const and volatile, which can provoke + // C compiler warnings. Silence them by casting + // all pointers to void*. (Eventually that will produce + // other warnings.) + if c := t.C.String(); c[len(c)-1] == '*' { + fmt.Fprintf(fgcc, "(void*)") + } fmt.Fprintf(fgcc, "a->p%d", i) } fmt.Fprintf(fgcc, ");\n")