Index: src/cmd/cgo/out.go |
=================================================================== |
--- a/src/cmd/cgo/out.go |
+++ b/src/cmd/cgo/out.go |
@@ -517,12 +517,16 @@ |
return |
} |
- ctype, _ := p.structType(n) |
+ ctype, offset := p.structType(n) |
// Gcc wrapper unpacks the C argument struct |
// and calls the actual C function. |
fmt.Fprintf(fgcc, "void\n") |
- fmt.Fprintf(fgcc, "_cgo%s%s(void *v)\n", cPrefix, n.Mangle) |
+ if offset != 0 { |
+ fmt.Fprintf(fgcc, "_cgo%s%s(void *v)\n", cPrefix, n.Mangle) |
+ } else { |
+ fmt.Fprintf(fgcc, "_cgo%s%s()\n", cPrefix, n.Mangle) |
+ } |
fmt.Fprintf(fgcc, "{\n") |
if n.AddError { |
fmt.Fprintf(fgcc, "\terrno = 0;\n") |
@@ -530,7 +534,9 @@ |
// We're trying to write a gcc struct that matches 6c/8c/5c's layout. |
// Use packed attribute to force no padding in this struct in case |
// gcc has different packing requirements. |
- fmt.Fprintf(fgcc, "\t%s %v *a = v;\n", ctype, p.packedAttribute()) |
+ if offset != 0 { |
+ fmt.Fprintf(fgcc, "\t%s %v *a = v;\n", ctype, p.packedAttribute()) |
+ } |
fmt.Fprintf(fgcc, "\t") |
if t := n.FuncType.Result; t != nil { |
fmt.Fprintf(fgcc, "a->r = ") |