Thank you
problem solved with your suggestion.

var PSlv (**C.Volume) = RPointer.v
lenght := int(RPointer.h.nvolumes)
sliceV := (*[1 << 30](*C.Volume))(unsafe.Pointer(PSlv))[:lenght:lenght]

the result is  []*C.Volume correct, where the pointer is null the slice 
value is nil

Alex

On Tuesday, May 23, 2017 at 3:42:26 PM UTC+2, Pablo Rozas Larraondo wrote:
>
> I'm thinking about the possibility of having something like [][]Volume in 
> Go. Do you know the size or number of Volumes in your struct?
>
> There's an example of converting **char into []string that might be useful:
> https://stackoverflow.com/questions/36188649/cgo-char-to-slice-string
>
>
>
> On Tuesday, May 23, 2017 at 8:39:12 PM UTC+10, alex martin wrote:
>>
>> Hi 
>> I have this structure in C created by rsl libray 
>>
>> typedef struct {
>>   Radar_header h;
>>   Volume **v;   
>> } Radar;
>>
>>
>> Using cgo i read the structure with 
>>
>>
>> Radar *readRad(char *fname) {
>>   return RSL_anyformat_to_radar(fname, NULL);
>> }
>>
>>
>> and call this function in go 
>>
>> RPointer := C.readRad(C.CString(os.Args[1]))
>>
>>
>> and i see the structure
>>
>> with fmt.Printf("%T",RPointer)    =>  *main._Ctype_struct___0
>>
>> with fmt.Printf("%+v",RPointer)   =>  &{h:{} _:[0 0 0 0] *v:0xe59b60*}
>>
>>
>> The field is a **C.Volume pointer.
>>
>> The question is: it's  possible with Golang list all C.Volume's struct 
>> pointed ?
>>
>>
>> like this   
>>
>>
>> for i := 0; i < int(RPointer.h.nvolumes); i++ {
>>
>>                      pv := *RPointer.v[i]
>>                      fmt.Printf("\nVOLUME Sweep %+v\n", *pv.sweep)
>>              }
>>
>>
>> the exit is type **C.struct___2 does not support indexing
>>
>>
>> I tried with unsafe.Pointer using 
>>
>>
>>
>> *puint1 := unsafe.Pointer(RPointer.v)*
>>
>>
>> *sizep := unsafe.Sizeof(RPointer.v)fmt.Printf("\npuint [%+v] -> + sizeoff 
>> [%+v]\n", puint1, unsafe.Pointer(uintptr(puint1)+sizep))*
>>
>>
>> and printf is puint [0xe59b60] -> + sizeoff [0xe59b68]
>>
>>
>> there is a casting like this 
>>
>>
>> volume2 := (*C.Volume)(*unsafe.Pointer(uintptr(puint1) + sizep))
>>
>>
>> Thanks
>>
>> Alex
>>
>>
>>
>>
>>

-- 
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.
For more options, visit https://groups.google.com/d/optout.

Reply via email to