You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to golang-nuts
Hi,
I want to use the function "C.GoStringsN"
this function expect a "*_Ctype_char" argument on first position.
I have an argument "_Ctypedef_MQ_CBI" which is "type _Ctypedef_MQ_CBI
*_Ctype_unsignedchar"
the problem is "char" and "unsigned char". In "C" this is no a problem
to cast
the both pointers but in "GO" I got errors like
6g -o _go_.6 MqS.cgo1.go send.cgo1.go read.cgo1.go _cgo_gotypes.go
read.go:62[read.cgo1.go:64]: cannot use bin.dat (type
_Ctypedef_MQ_CBI) as type *_Ctype_char in function argument
Question: How I can cast pointers in "GO"
mfg, Andreas Otto
My Code:
type Binary struct {
dat C.MQ_CBI
len C.MQ_SIZE
}
func Binary2String(ret uint32, bin Binary) (uint32, string) {
if ret == ERROR {
return ret, ""
}
return ret, C.GoStringN(bin.dat, C.int(bin.len))
}
Russ Cox
unread,
Nov 16, 2010, 1:41:56 PM11/16/10
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to gnu.bash, golang-nuts
import "unsafe" x := (*C.char)(unsafe.Pointer(y))
gnu.bash
unread,
Nov 16, 2010, 1:54:39 PM11/16/10
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to golang-nuts
works...
func Binary2String(ret MqSException, bin Binary) (MqSException,