#Single pointer to pointer to many

1 messages · Page 1 of 1 (latest)

grave mountain
#

Hello,

I use a C api that uses [*] pointers for array passing. However I just want to pass one item, and if I do &my_item the compiler complains that it wants a [*] pointer, not a single one.

I can use a pointer cast to make the code compile ( @ptrCast([*]TargetType, &my_item)), but I was wondering if there is a simpler way than that because it forces me to go lookup the value of my_item

Thanks !

stiff saffron
#

&my_item[0]

#

Wait that's backwards sorry

#

Yeah you either have to ptrCast or store my_item in an array

#

(which can be an array of length 1)

#

So var my_item: [1]TargetType

#

Then a pointer to my_item will implicitly convert to a many pointer