]> Cypherpunks repositories - gostls13.git/commit
cmd/cgo: disable inappropriate warnings when the gcc struct is empty
authorsnyh <snyh@snyh.org>
Fri, 18 Jul 2014 06:47:21 +0000 (02:47 -0400)
committerShenghou Ma <minux@golang.org>
Fri, 18 Jul 2014 06:47:21 +0000 (02:47 -0400)
commit086df1dc77710cb6fa06ca561e1fafd5a4c78d8e
tree9ad7924691e716a7a12771d58d5054aeb5f48ba5
parentec5d7ba95c4ae49517f832644979ecbefdf657cc
cmd/cgo: disable inappropriate warnings when the gcc struct is empty

package main
//#cgo CFLAGS: -Wall
//void test() {}
import "C"
func main() {
    C.test()
}

This code will cause gcc issuing warnings about unused variable.

This commit use offset of the second return value of
Packages.structType to detect whether the gcc struct is empty,
and if it's directly invoke the C function instead of writing an
unused code.

LGTM=dave, minux
R=golang-codereviews, iant, minux, dave
CC=golang-codereviews
https://golang.org/cl/109640045
misc/cgo/test/empty.go [new file with mode: 0644]
src/cmd/cgo/out.go