Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
cmd/cgo: inconsistent definitions for C.sfColor #8133
What does 'go version' print? go version go1.3beta2 +1af13552a260 Sun Jun 01 13:57:46 2014 -0400 linux/amd64 What steps reproduce the problem? If possible, include a link to a program on play.golang.org. The p1 repo doesn't compile while the p2 repo does. The only difference is that p1 uses multiple source files while p2 only uses a single source file. 1. go get github.com/mewmew/playground/p1 2. Prints the cgo error "inconsistent definitions for C.sfColor" 3. go get github.com/mewmew/playground/p2 4. Compiles without any errors. The following files are present in the p1 repo: * "a.go": http://play.golang.org/p/zQLkeed3id * "b.go": http://play.golang.org/p/Uj09NA58LZ * "Color.h": http://play.golang.org/p/fBghn23MNw The following files are present in the p1 repo: * "ab.go": http://play.golang.org/p/_nlL3rP6JB * "Color.h": http://play.golang.org/p/fBghn23MNw What happened? p1 fails to compile, while p2 succeeds. What should have happened instead? Both p1 and p2 should compile without any errors. Please provide any additional information below. This issue may have been introduced recently, and if so most likely by rev 177ed19da89fc68391d6e2411163ffe777180637.
I believe the problem here is specifically with a C .h file that does a typedef of an untagged struct. If the Go package has more than one file that import "C" and #include that .h file, then we get this error from cgo. In cgo terms, the problem is that the typedef has been given the Go name of the struct. Since the structs are untagged, they get Go names like _Ctype_struct___INDEX, where INDEX differs. So we appears to have the same typedef referring to two different structs.