You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
package a
import "C"
type interface foo {
bar() C.Uint32
}
package b
import "C"
import "a"
type struct foo {}
var asdf a.foo = &foo{}
func (*foo) bar() C.Uint32 {
}
If possible, provide a recipe for reproducing the error.
A complete runnable program is good.
A link on play.golang.org is best.
What did you expect to see?
Code compiles
What did you see instead?
cannot use software literal (type *foo) as type a.foo in assignment:
*software does not implement a.foo (wrong type for bar method)
have bar() C.Uint32
want bar() a.C.Uint32
The text was updated successfully, but these errors were encountered:
Am I not supposed to pass C types between packages?
AlexRouSg
changed the title
Cannot assign strut to interface type of another package when interface type uses certain C types
Cannot assign strut to interface type of another package when interface type uses C types
May 31, 2017
Cgo translates C types into equivalent unexported Go types. Because the translations are unexported, a Go package should not expose C types in its exported API: a C type used in one Go package is different from the same C type used in another.
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (
go version
)?go1.8.1 linux/amd64
What operating system and processor architecture are you using (
go env
)?GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/chotepud/go"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build397619697=/tmp/go-build -gno-record-gcc-switches"
CXX="g++"
CGO_ENABLED="1"
PKG_CONFIG="pkg-config"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
What did you do?
If possible, provide a recipe for reproducing the error.
A complete runnable program is good.
A link on play.golang.org is best.
What did you expect to see?
Code compiles
What did you see instead?
cannot use software literal (type *foo) as type a.foo in assignment:
*software does not implement a.foo (wrong type for bar method)
have bar() C.Uint32
want bar() a.C.Uint32
The text was updated successfully, but these errors were encountered: