From 2eb00d57b40a7f806fd611c2303289bb11f77d15 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Tue, 7 Sep 2010 09:54:20 -0400 Subject: [PATCH] cgo: silence warning for C call returning const pointer Fix suggested by Albert Strasheim. R=adg CC=golang-dev https://golang.org/cl/2154041 --- src/cmd/cgo/out.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/cmd/cgo/out.go b/src/cmd/cgo/out.go index 906b2c511f7..eb39338684b 100644 --- a/src/cmd/cgo/out.go +++ b/src/cmd/cgo/out.go @@ -107,7 +107,11 @@ func (p *Package) structType(n *Name) (string, int64) { fmt.Fprintf(&buf, "\t\tchar __pad%d[%d];\n", off, pad) off += pad } - fmt.Fprintf(&buf, "\t\t%s r;\n", t.C) + qual := "" + if t.C[len(t.C)-1] == '*' { + qual = "const " + } + fmt.Fprintf(&buf, "\t\t%s%s r;\n", qual, t.C) off += t.Size } if off%p.PtrSize != 0 {