Skip to content

cmd/cgo: incomplete typedef can cause "inconsistent definitions" error #26430

Closed
@ianlancetaylor

Description

@ianlancetaylor

Using an incomplete typedef seems to sometimes cause an "inconsistent definitions" error from cgo.

GOPATH/src/a/a.go:

package a

// typedef struct S ST;
// ST* M() {}
import "C"

func F1() {
	C.M()
}

GOPATH/src/a/b.go:

package a

// typedef struct S ST;
// struct S { int f; };
import "C"

func F2(p *C.ST) {
	p.f = 1
}
> go build a
# a
inconsistent definitions for C.ST
> ~/go1.10/bin/go build a
> # no error

Reverting https://golang.org/cl/123177 (b888a62) fixes cgo on tip. CC @randall77

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.release-blocker

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions