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