--- /dev/null
+// Copyright 2014 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package cgotest
+
+/*
+#cgo CFLAGS: -Werror=unused-variable
+void funcWithoutAnyParams() {}
+*/
+import "C"
+
+// Only test whether this can be compiled, unused
+// variable (e.g. empty gcc strut) could cause
+// warning/error under stricter CFLAGS.
+func testEmptyGccStruct() {
+ C.funcWithoutAnyParams()
+}
return
}
- ctype, _ := p.structType(n)
+ ctype, offset := p.structType(n)
// Gcc wrapper unpacks the C argument struct
// and calls the actual C function.
// 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 = ")