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: exported go functions can't use C struct types (regression from 1.2) #8148
Consider: http://play.golang.org/p/UuuyA-zII7 This package compiles in go 1.2 and the GetNum go function returns 42 as expected. In go 1.3 the compilation fails with: In file included from $WORK/cgobreak/_obj/_cgo_export.c:2: ./code.go:40:30: warning: declaration of 'struct __0' will not be visible outside of this function [-Wvisibility] ./code.go:40:12: error: conflicting types for 'goCallback' ./code.go:6:6: note: previous declaration is here /var/folders/52/y5kwxpqj1vqd3n6j1ndnx3200000gn/T/go-build778103108/cgobreak/_obj/_cgo_export.c:8:23: warning: declaration of 'struct __0' will not be visible outside of this function [-Wvisibility] /var/folders/52/y5kwxpqj1vqd3n6j1ndnx3200000gn/T/go-build778103108/cgobreak/_obj/_cgo_export.c:8:5: error: conflicting types for 'goCallback' ./code.go:6:6: note: previous declaration is here Comparing the results of manually running cgo of both versions shows that the function generated by the export directive goes from: int goCallback(Gen* p0) in 1.2 to: int goCallback(struct __0* p0) Essentially the C-type is ignored and replaced with an unknown, anonymous struct pointer type which causes clang to fail to compile it. Tested on darwin/amd64 with both 1.2.2 and tip.