https://kotlinlang.org logo
#kotlin-native
Title
# kotlin-native
z

zt

07/29/2022, 1:41 AM
I'm using cinterop to generate bindings the xlib library and I'm wondering if theres some way to define conversions for a specific type. Like I want to somehow make it use kotlin primitive booleans for the Bool macro in the header file
l

Landry Norris

07/29/2022, 3:46 PM
I don’t know that there’s a way to automatically convert, but I generally write a Boolean.toBool(): Int and a Int.toKBoolean(): Boolean and call these.
Boolean.toBool() = if(this) 1 else 0 Int.toKBoolean() = this != 0
4 Views