Is it possible to pass through an array of C point...
# kotlin-native
n
Is it possible to pass through an array of C pointers to a C function as a single parameter? There is a GTK function which appears to take a array of GtkWidget, here is the definition:
Copy code
public fun gtk_container_add(container: CValuesRef<GtkContainer>?, widget: CValuesRef<GtkWidget>?): Unit
Would like to add multiple GTK widgets to a GTK container using a single function call. If three or more widgets need to be added to a container then it would be tedious to call the same function multiple times.
Looks as though it isn't possible. Defined a function as a workaround to deal with the GTK API limitation.
o
per https://developer.gnome.org/gtk3/stable/GtkContainer.html#gtk-container-add this function takes single argument, not an array.
cValuesOf
wil produce C array.
👍 1
n
Can get a bit confusing when seeing CValue, CValues, and CValuesRef, which all look very similar but have subtle differences between them.
2
m
Array of pointers would be
CPointer<CPointerVar<GtkWidget>>
n
At which point a typealias starts to look like a good option.
m
It just mirrors C typesystem, array of pointers is
GtkWidget**
. If IDEA/CLion could show C header instead of useless interop stub - maybe it would be less confusing.
o
For people who know C :)