Hi guys, I have a problem regarding a `cinterop` ...
# kotlin-native
v
Hi guys, I have a problem regarding a
cinterop
library and the architectures:
arm32
and
x64
. I am using the
Cairo
library as
cinterop
library for both targets. After the
cinterop
process the following struct:
Copy code
typedef struct {
    unsigned long        index;
    double               x;
    double               y;
} cairo_glyph_t;
is mapped for
arm32
to:
Copy code
@kotlinx.cinterop.internal.CStruct public final class cairo_glyph_t public constructor(rawPtr: kotlinx.cinterop.NativePtr /* = kotlin.native.internal.NativePtr */) : kotlinx.cinterop.CStructVar {
    public companion object : kotlinx.cinterop.CStructVar.Type {
    }

    public final var index: kotlin.UInt /* compiled code */

    public final var x: kotlin.Double /* compiled code */

    public final var y: kotlin.Double /* compiled code */
}
and for
x64
to:
Copy code
@kotlinx.cinterop.internal.CStruct public final class cairo_glyph_t public constructor(rawPtr: kotlinx.cinterop.NativePtr /* = kotlin.native.internal.NativePtr */) : kotlinx.cinterop.CStructVar {
    public companion object : kotlinx.cinterop.CStructVar.Type {
    }

    public final var index: kotlin.ULong /* compiled code */

    public final var x: kotlin.Double /* compiled code */

    public final var y: kotlin.Double /* compiled code */
}
As you can see the
index
field has different types. I am trying to write the code once and compile it for both platforms, but the following example does not compile:
Copy code
val glyph = cValue<cairo_glyph_t> {
  index =  0
  x = 0.0
  y = 0.0
}
Does anybody have an idea how I can overcome this issue? Thanks in advance!
d
This can be overcome by using
index = 0.convert()
. It basically gives you implicit casting.
v
Great! Thanks!