I'm also wondering: I've had an easy time using `B...
# kotlin-native
a
I'm also wondering: I've had an easy time using `ByteArray`s for C functions which want to accept a
char **
to write to, but what would be the best way to pass, say, an
int *
or any other primitive pointer? I can use
alloc
within
memScoped
, but is there any way to use a variable on the stack rather than the heap?
n
For the CPointer stuff the heap has to be used.
The stack in Kotlin Native programs/libraries can only be used on the Kotlin side.
Kotlin has very limited stack support, although there are Value classes ( https://kotlinlang.org/docs/inline-classes.html ) which is currently in development. It is unknown if a Value class can be passed through as a C struct to a C function (by value or reference/pointer). Having such a feature would be very useful (makes things easier/convenient), and would cover some use cases.
a
Thanks! This is helpful to know. Hopefully we get the chance to have more control over memory for C interop in the future.