I want to create a struct from c, but get an excep...
# kotlin-native
l
I want to create a struct from c, but get an exception “Native interop types constructors must not be called directly” , so i use
alloc<*>
instead. Is it a way to invoke constructor function when i call
alloc<*>
? because the params is final in klib, i can not assign value after
alloc<*>
. my code:
Copy code
memScoped {
    val info = alloc<GrMtlTextureInfo>()
    info.fTexture = _texture.objcPtr() // fTexture is final in klib
    renderTarget = GrBackendRenderTarget(480, 320, 1, info.reinterpret())
}
d
C doesn't have constructors though. Do you just want to call some random C function?
Is fTexture const?
l
I m using Skia, it is a C++ library, which is not supported by the K/N. Maybe that’s the reason
d
Ah yes, C++ hard. Must wrap.
❤️ 1