Vlad Balan
03/17/2020, 6:37 PMcinterop
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:
typedef struct {
unsigned long index;
double x;
double y;
} cairo_glyph_t;
is mapped for arm32
to:
@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:
@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:
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!Dominaezzz
03/17/2020, 6:39 PMindex = 0.convert()
. It basically gives you implicit casting.Vlad Balan
03/17/2020, 6:40 PM