]> Cypherpunks repositories - gostls13.git/commitdiff
cgo: silence warning for C call returning const pointer
authorRuss Cox <rsc@golang.org>
Tue, 7 Sep 2010 13:54:20 +0000 (09:54 -0400)
committerRuss Cox <rsc@golang.org>
Tue, 7 Sep 2010 13:54:20 +0000 (09:54 -0400)
Fix suggested by Albert Strasheim.

R=adg
CC=golang-dev
https://golang.org/cl/2154041

src/cmd/cgo/out.go

index 906b2c511f7d3180b450878a3bb00fe547cd9045..eb39338684bc1340cec0bac6d7d7ac2d4cb07d3f 100644 (file)
@@ -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 {