1
0
mirror of https://github.com/golang/go synced 2024-11-22 08:44:41 -07:00

cmd/cgo: do not output empty struct for -cdefs

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/9574043
This commit is contained in:
Alex Brainman 2013-05-25 20:53:55 +10:00
parent 7472ce0e58
commit a2ec8abd2d

View File

@ -204,6 +204,11 @@ func (p *Package) cdefs(f *File, srcfile string) string {
// byte Z[4];
// }
if strings.HasPrefix(line, "type ") && strings.HasSuffix(line, " struct {") {
if len(lines) > i+1 && lines[i+1] == "}" {
// do not output empty struct
i++
continue
}
s := line[len("type ") : len(line)-len(" struct {")]
printf("struct %s {\n", s)
for i++; i < len(lines) && lines[i] != "}"; i++ {