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 cgotest
/*#cgo LDFLAGS: -framework CoreFoundation#include <CoreFoundation/CFBase.h>#include <CoreFoundation/CFString.h>*/import"C"// MyFunc demonstrates compilation problem.funcMyFunc() {
vartypeRef C.CFTypeRefcfStringRef:=C.CFCopyDescription(typeRef)
// This cast triggers 'cannot convert cfStringRef (type _Ctype_CFStringRef) to type _Ctype_CFTypeRef'deferC.CFRelease(C.CFTypeRef(cfStringRef))
// Reference C.CFStringRef explicitly in code. Uncomment this line to allow compilation.// var _ C.CFStringRef
}
Wordy description...
I want to cast from C.CFStringRef to C.CFTypeRef in order to call C.CFRelease(...). This is a valid cast as both types are represented as uintptrs (as per https://go-review.googlesource.com/c/go/+/66332).
What is weird (and I believe a bug) is that the code does indeed compile if the C.CFStringRef type is mentioned in the Go code. i.e. uncomment the last line in that func and the compilation error goes away.
A possibly related thing that I also find weird is that you need the CFString.h include even though the CFStringRef type is defined in CFBase.h. Without that (and the last line uncommented) I get the same compilation error.
What did you expect to see?
Successful compilation
What did you see instead?
cannot convert cfStringRef (type _Ctype_CFStringRef) to type _Ctype_CFTypeRef
The text was updated successfully, but these errors were encountered:
What version of Go are you using (
go version
)?go1.10 darwin/amd64
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/ben/Library/Caches/go-build"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/ben/Documents/Coding/go"
GORACE=""
GOROOT="/usr/local/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/gb/hp3qsnwd0jz64k6gpnnt2ws40000gn/T/go-build705521711=/tmp/go-build -gno-record-gcc-switches -fno-common"
What did you do?
Below code demonstrates the problem.
Wordy description...
I want to cast from C.CFStringRef to C.CFTypeRef in order to call C.CFRelease(...). This is a valid cast as both types are represented as uintptrs (as per https://go-review.googlesource.com/c/go/+/66332).
What is weird (and I believe a bug) is that the code does indeed compile if the C.CFStringRef type is mentioned in the Go code. i.e. uncomment the last line in that func and the compilation error goes away.
A possibly related thing that I also find weird is that you need the CFString.h include even though the CFStringRef type is defined in CFBase.h. Without that (and the last line uncommented) I get the same compilation error.
What did you expect to see?
Successful compilation
What did you see instead?
cannot convert cfStringRef (type _Ctype_CFStringRef) to type _Ctype_CFTypeRef
The text was updated successfully, but these errors were encountered: