What does "argv" hold?

Can it be a concrete type, not an interface ? That would allow passing it - 
or if you copy it to a C.malloc-ed array..

2020. január 29., szerda 23:12:37 UTC+1 időpontban aotto1...@gmail.com a 
következőt írta:
>
> Hi,
>
> I try to use a *C* library with *GO* and have a small problem passing a 
> *GO* pointer through *C* into a *GO* callback.
> If I set: "*export GODEBUG=cgocheck=0*" everything works fine but without 
> I get the error from above
>
> Detail: I want to pass "*argv*" through *C* back to *GO*, the lifetime of 
> the *argv* is only the lifetime of the *Send* function call
>
> // PROBLEM: [ErrorCatch] runtime error: cgo argument has Go pointer to Go 
> pointer                                  
> // SOLVE:   export 
> GODEBUG=cgocheck=0                                                            
>                   
>
> func (this *MqC) Send (callSig string, argv ...interface{}) 
> {                                                      
>   hdl := 
> this.getCTX()                                                                 
>                             
>
>   callSig_ptr := 
> (C.MQ_CST)(C.CString(callSig))                                                
>                     
>
>   defer 
> C.free((unsafe.Pointer)(callSig_ptr))                                         
>                              
>
>                                                                               
>                                      
>
>   var errVal C.enum_MqErrorE = C.gomsgque_Send(hdl, callSig_ptr, 
> C.MQ_INT(len(argv)), unsafe.Pointer(&argv))       
>                                                                               
>                                      
>
>   if (errVal > C.MQ_CONTINUE) { MqErrorC_Check(C.MQ_MNG(hdl), errVal) 
> }                                            
> }                                                                             
>                                      
>
>
> The callback is:
>
> //export atomSet
> func atomSet( hdl   C.MQ_MNG, objv  unsafe.Pointer, skip  C.MQ_INT, typ 
> C.enum_MqSendE,
>                 inP  unsafe.Pointer) C.enum_MqErrorE {
>   ifc := (*(*[]interface{})(objv))[skip]
> ...
> }
>
> so, what is the GO solution for pass-through problem.
>
> thanks… mfg ao
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/5b288ff4-e0e1-46ad-b452-c0eae07eda84%40googlegroups.com.

Reply via email to