mirror of
https://github.com/golang/go
synced 2024-11-26 00:57:56 -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:
parent
7472ce0e58
commit
a2ec8abd2d
@ -204,6 +204,11 @@ func (p *Package) cdefs(f *File, srcfile string) string {
|
|||||||
// byte Z[4];
|
// byte Z[4];
|
||||||
// }
|
// }
|
||||||
if strings.HasPrefix(line, "type ") && strings.HasSuffix(line, " struct {") {
|
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 {")]
|
s := line[len("type ") : len(line)-len(" struct {")]
|
||||||
printf("struct %s {\n", s)
|
printf("struct %s {\n", s)
|
||||||
for i++; i < len(lines) && lines[i] != "}"; i++ {
|
for i++; i < len(lines) && lines[i] != "}"; i++ {
|
||||||
|
Loading…
Reference in New Issue
Block a user