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
What version of Go are you using (go version)?
go version go1.6.2 linux/amd64
What operating system and processor architecture are you using (go env)?
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/opt/gopath"
GORACE=""
GOROOT="/usr/lib/go-1.6"
GOTOOLDIR="/usr/lib/go-1.6/pkg/tool/linux_amd64"
GO15VENDOREXPERIMENT="1"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0"
CXX="g++"
CGO_ENABLED="1"
What did you do?
In my program, I wrote a func UcharToByte(c, C.uchar) in which it convert the parameter C.uchar to byte and return it. But when I invoke the func, it throw an error: cannot use c (type C.uchar) as type utils.C.uchar in argument to utils.UcharToByte
Here is my code below.
a. $GOPATH/src/github.com/warm3snow/utils/utils.go
package main
import "C"
import (
"fmt"
"github.com/warm3snow/utils"
)
func main() {
var c C.uchar = 'm'
var b byte = utils.UcharToByte(c)
fmt.Printf("%c\n", b)
}
What did you expect to see?
I want to convert C.uchar to byte in golang. In the simple example above, I expect to see output "m"
What did you see instead?
I got this err: cannot use c (type C.uchar) as type utils.C.uchar in argument to utils.UcharToByte.
And when I use utils.UcharToByte, it also throws an error.
The text was updated successfully, but these errors were encountered:
warm3snow
changed the title
cgo error : convert C.uchar to byte in golang
cgo error : can not convert C.uchar to byte by a func in golang
Aug 15, 2016
go version
)?go version go1.6.2 linux/amd64
go env
)?GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/opt/gopath"
GORACE=""
GOROOT="/usr/lib/go-1.6"
GOTOOLDIR="/usr/lib/go-1.6/pkg/tool/linux_amd64"
GO15VENDOREXPERIMENT="1"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0"
CXX="g++"
CGO_ENABLED="1"
In my program, I wrote a func UcharToByte(c, C.uchar) in which it convert the parameter C.uchar to byte and return it. But when I invoke the func, it throw an error: cannot use c (type C.uchar) as type utils.C.uchar in argument to utils.UcharToByte
Here is my code below.
a. $GOPATH/src/github.com/warm3snow/utils/utils.go
b. /home/xxx/workspace/test.go
I want to convert C.uchar to byte in golang. In the simple example above, I expect to see output "m"
I got this err: cannot use c (type C.uchar) as type utils.C.uchar in argument to utils.UcharToByte.
And when I use utils.UcharToByte, it also throws an error.
The text was updated successfully, but these errors were encountered: