params[0].data = unsafe.Pointer(cstr)

Note no & cuz cstr is already a pointer and &cstr is a pointer to a pointer

On Friday, 29 January 2021 at 9:20:41 am UTC+8 yue.ni...@gmail.com wrote:

> Hi,
>
>   I have the following struct in C
> ======================
> struct DataStruct
> {
>     const char *name;
>     const void *data;
>     int type;
>     int arraylength;
>     size_t count;
>     int flags;
> };
> ======================
>
>   I am trying to pass a string/(char *) to data. What is the correct 
> approach ? I believe the other parameters are being passed successfully
>
> My attempt
>
> ======================
> var params [2]C.struct_DataStruct
> params[0].name = C.CString("type")
> // cstr := C.CString("apistream")
> // params[0].data = unsafe.Pointer(&cstr)
> params[0]._type = C.int(0)
> params[0].arraylength = C.int(0)
> params[0].flags = C.int(0)
> ======================
>
> Cheers
>

-- 
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/f17b1e2d-e10a-4a59-bf63-e90045960f43n%40googlegroups.com.

Reply via email to