https://kotlinlang.org logo
Join the conversationJoin Slack
Channels
100daysofcode
100daysofkotlin
100daysofkotlin-2021
advent-of-code
aem
ai
alexa
algeria
algolialibraries
amsterdam
android
android-architecture
android-databinding
android-studio
androidgithubprojects
androidthings
androidx
androidx-xprocessing
anime
anko
announcements
apollo-kotlin
appintro
arabic
argentina
arkenv
arksemdevteam
armenia
arrow
arrow-contributors
arrow-meta
ass
atlanta
atm17
atrium
austin
australia
austria
awesome-kotlin
ballast
bangladesh
barcelona
bayarea
bazel
beepiz-libraries
belgium
berlin
big-data
books
boston
brazil
brikk
budapest
build
build-tools
bulgaria
bydgoszcz
cambodia
canada
carrat
carrat-dev
carrat-feed
chicago
chile
china
chucker
cincinnati-user-group
cli
clikt
cloudfoundry
cn
cobalt
code-coverage
codeforces
codemash-precompiler
codereview
codingame
codingconventions
coimbatore
collaborations
colombia
colorado
communities
competitive-programming
competitivecoding
compiler
compose
compose-android
compose-desktop
compose-hiring
compose-ios
compose-mp
compose-ui-showcase
compose-wear
compose-web
connect-audit-events
corda
cork
coroutines
couchbase
coursera
croatia
cryptography
cscenter-course-2016
cucumber-bdd
cyprus
czech
dagger
data2viz
databinding
datascience
dckotlin
debugging
decompose
decouple
denmark
deprecated
detekt
detekt-hint
dev-core
dfw
docs-revamped
dokka
domain-driven-design
doodle
dsl
dublin
dutch
eap
eclipse
ecuador
edinburgh
education
effective-kotlin
effectivekotlin
emacs
embedded-kotlin
estatik
event21-community-content
events
exposed
failgood
fb-internal-demo
feed
firebase
flow
fluid-libraries
forkhandles
forum
fosdem
fp-in-kotlin
framework-elide
freenode
french
fritz2
fuchsia
functional
funktionale
gamedev
ge-kotlin
general-advice
georgia
geospatial
german-lang
getting-started
github-workflows-kt
glance
godot-kotlin
google-io
gradle
graphic
graphkool
graphql
graphql-kotlin
graviton-browser
greece
grpc
gsoc
gui
hackathons
hacktoberfest
hamburg
hamkrest
helios
helsinki
hexagon
hibernate
hikari-cp
hire-me
hiring
hongkong
hoplite
http4k
hungary
hyderabad
image-processing
india
indonesia
inkremental
intellij
intellij-plugins
intellij-tricks
internships
introduce-yourself
io
ios
iran
israel
istanbulcoders
italian
jackson-kotlin
jadx
japanese
jasync-sql
java-to-kotlin-refactoring
javadevelopers
javafx
javalin
javascript
jdbi
jhipster-kotlin
jobsworldwide
jpa
jshdq
juul-libraries
jvm-ir-backend-feedback
jxadapter
k2-early-adopters
kaal
kafka
kakao
kalasim
kapt
karachi
karg
karlsruhe
kash_shell
kaskade
kbuild
kdbc
kgen-doc-tools
kgraphql
kinta
klaxon
klock
kloudformation
kmdc
kmm-español
kmongo
knbt
knote
koalaql
koans
kobalt
kobweb
kodein
kodex
kohesive
koin
koin-dev
komapper
kondor-json
kong
kontent
kontributors
korau
korean
korge
korim
korio
korlibs
korte
kotest
kotest-contributors
kotless
kotlick
kotlin-asia
kotlin-beam
kotlin-by-example
kotlin-csv
kotlin-data-storage
kotlin-foundation
kotlin-fuel
kotlin-in-action
kotlin-inject
kotlin-latam
kotlin-logging
kotlin-multiplatform-contest
kotlin-mumbai
kotlin-native
kotlin-pakistan
kotlin-plugin
kotlin-pune
kotlin-roadmap
kotlin-samples
kotlin-sap
kotlin-serbia
kotlin-spark
kotlin-szeged
kotlin-website
kotlinacademy
kotlinbot
kotlinconf
kotlindl
kotlinforbeginners
kotlingforbeginners
kotlinlondon
kotlinmad
kotlinprogrammers
kotlinsu
kotlintest
kotlintest-devs
kotlintlv
kotlinultimatechallenge
kotlinx-datetime
kotlinx-files
kotlinx-html
kotrix
kotson
kovenant
kprompt
kraph
krawler
kroto-plus
ksp
ktcc
ktfmt
ktlint
ktor
ktp
kubed
kug-leads
kug-torino
kvision
kweb
lambdaworld_cadiz
lanark
language-evolution
language-proposals
latvia
leakcanary
leedskotlinusergroup
lets-have-fun
libgdx
libkgd
library-development
linkeddata
lithuania
london
losangeles
lottie
love
lychee
macedonia
machinelearningbawas
madrid
malaysia
mathematics
meetkotlin
memes
meta
metro-detroit
mexico
miami
micronaut
minnesota
minutest
mirror
mockk
moko
moldova
monsterpuzzle
montreal
moonbean
morocco
motionlayout
mpapt
mu
multiplatform
mumbai
munich
mvikotlin
mvrx
myndocs-oauth2-server
naming
navigation-architecture-component
nepal
new-mexico
new-zealand
newname
nigeria
nodejs
norway
npm-publish
nyc
oceania
ohio-kotlin-users
oldenburg
oolong
opensource
orbit-mvi
osgi
otpisani
package-search
pakistan
panamá
pattern-matching
pbandk
pdx
peru
philippines
phoenix
pinoy
pocketgitclient
polish
popkorn
portugal
practical-functional-programming
proguard
prozis-android-backup
pyhsikal
python
python-contributors
quasar
random
re
react
reaktive
realm
realworldkotlin
reductor
reduks
redux
redux-kotlin
refactoring-to-kotlin
reflect
refreshversions
reports
result
rethink
revolver
rhein-main
rocksdb
romania
room
rpi-pico
rsocket
russian
russian_feed
russian-kotlinasfirst
rx
rxjava
san-diego
science
scotland
scrcast
scrimage
script
scripting
seattle
serialization
server
sg-user-group
singapore
skia-wasm-interop-temp
skrape-it
slovak
snake
sofl-user-group
southafrica
spacemacs
spain
spanish
speaking
spek
spin
splitties
spotify-mobius
spring
spring-security
squarelibraries
stackoverflow
stacks
stayhungrystayfoolish
stdlib
stlouis
strife-discord-lib
strikt
students
stuttgart
sudan
swagger-gradle-codegen
swarm
sweden
swing
swiss-user-group
switzerland
talking-kotlin
tallinn
tampa
teamcity
tegal
tempe
tensorflow
terminal
test
testing
testtestest
texas
tgbotapi
thailand
tornadofx
touchlab-tools
training
tricity-kotlin-user-group
trójmiasto
truth
tunisia
turkey
turkiye
twitter-feed
uae
udacityindia
uk
ukrainian
uniflow
unkonf
uruguay
utah
uuid
vancouver
vankotlin
vertx
videos
vienna
vietnam
vim
vkug
vuejs
web-mpp
webassembly
webrtc
wimix_sentry
wwdc
zircon
Powered by Linen
kotlin-native
  • e

    Ergun Uğur Güner

    12/11/2022, 11:27 AM
    Hello there everyone, I just wanted to ask that what is the best way to use the coroutines in application class. I found several examples but could not make sure are they safe codes and which one is best from performance perspective. Thank you
  • e

    Eric Womer

    12/11/2022, 12:31 PM
    How do I use mutable states + jetpack compose to use a button to switch images?
  • e

    Eric Womer

    12/11/2022, 12:32 PM
    *if you can't use remember in the applications class since you have to use remember in a @Composable function
  • e

    Eric Womer

    12/11/2022, 12:34 PM
    I get this Type 'TypeVariable(T)' has no method 'getValue(Nothing?, KProperty<*>)' and thus it cannot serve as a delegate trying to follow https://dev.to/zachklipp/remember-mutablestateof-a-cheat-sheet-10ma
  • e

    Eric Womer

    12/11/2022, 12:47 PM
    Tried to simplify it and now the app crashes.
  • e

    Eric Womer

    12/11/2022, 12:51 PM
    Fixed it, my issue when I initially set the value during the var creation it wasn't the correct 'id' number since it was for xml vector images.
  • e

    Eric Womer

    12/11/2022, 1:14 PM
    When will Jetpack Compose be availiable for iOS?
    i
    j
    +3
    • 6
    • 12
  • t

    Todd

    12/11/2022, 8:38 PM
    Does kotlin native currently not support hash codes changing throughout the lifecycle of a class for data classes? Details in 🧵
    e
    v
    • 3
    • 8
  • u

    uli

    12/14/2022, 9:43 AM
    Hi all, i am hunting a memory leak and suspsect it might be related to
    refTo
    . I am passing a ByteArray reference by calling bytes.refTo to POSIX
    read
    and now wonder when the pinning will be undone? I see that the
    CValuesRef
    returned by
    getPointer
    takes an
    AutofreeScope
    . Where does that come from? And when is it cleared? I.e. what is the lifetime of a
    CValuesRef
    returned by
    refTo
    ?
    d
    • 2
    • 6
  • m

    Moussa

    12/14/2022, 11:19 PM
    Hi all, I have multi module kmm project that support the following four targets • iOS • Android • JVM • JS Some of these modules depend on each other ex: Module A doesn’t have any dependencies Module B depend on Module A and a pod project for the iOS Module C depend on Module B Now, Module C will contains all the dependencies that Module B have along with the pod project. Is there is a way not to include all Module B dependencies inside module C?
    u
    k
    t
    • 4
    • 22
  • m

    Moussa

    12/15/2022, 3:06 PM
    Hi all, I have an error that I’m not sure if it is a bug or not. Whenever I have a module that import a pod file in it, during the running of
    :linkDebugTestIosSimulatorArm64
    I get the following error:
    e: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld invocation reported errors
    The /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld command returned non-zero exit code: 1.
    output:
    ld: warning: object file (/var/folders/sd/vq_ngt5j7kqfzb0t3z91t5g40000gn/T/konan_temp6320318283573195829/result.o) was built for newer iOS Simulator version (14.0) than being linked (9.0)
    
    Undefined symbols for architecture arm64:
      "_OBJC_CLASS_$__TtC10ModuleAKMMFunctions", referenced from:
          objc-class-ref in result.o
    ld: symbol(s) not found for architecture arm64
    P.S Only one class have the annotation
    @objc
    (KMMFunctions) so that I can easily use the pod implementation without any hassles. The whole pod module is running with no issues alone and after importing it to xcode project. PodSpec is:
    s.ios.deployment_target = '13.0'
    s.osx.deployment_target  = '12.0'
    s.tvos.deployment_target = '13.0'
    s.watchos.deployment_target = '8.0'
    cocoapods {
        this.summary = "Module Summary"
        this.version = rootProject.version.toString()
        this.authors = "Me"
        this.ios.deploymentTarget = "13.0"
        this.osx.deploymentTarget = "12.0"
        this.tvos.deploymentTarget = "13.0"
        this.watchos.deploymentTarget = "8.0"
        framework {
            this.baseName = currentModuleName
        }
        pod("LOCAL POD") {
            version = "1.0.0"
            source = path(project.file("../iOSLibs/POD FOLDER NAME"))
        }
    }
    Kotlin v1.7.21 IntelliJ IDEA Ultimate v2022.3
  • r

    Reuben F

    12/15/2022, 10:01 PM
    hi, is there online documentation for the platform.posix.* library?
    m
    • 2
    • 5
  • g

    Gavin Novate

    12/16/2022, 1:41 PM
    Hi, I found that on Kotlin Native, the time-consuming of throwing and catching exceptions is about 5~10 times that of JVM. Is this problem known? Below is my test code, they run on the same device.
    fun main(args: Array<String>) {
        throwTest()
    }
    
    var createExceptionTime: Duration = Duration.ZERO
    
    @OptIn(ExperimentalTime::class)
    fun throwTest() {
        repeat(20) {
            createExceptionTime = Duration.ZERO
            measureTime {
                repeat(100) {
                    runCatching {
                        throwException(100)
                    }
                }
            }.also {
                println("Throw Performance Test:totalTime=$it throwTime=${it - createExceptionTime} createErrorTime=$createExceptionTime")
            }
        }
    }
    
    
    @OptIn(ExperimentalTime::class)
    fun throwException(deep: Int) {
        if (deep == 0) throw measureTimedValue { RuntimeException() }.apply { createExceptionTime += duration }.value
        throwException(deep - 1)
    }
    Logs on Jvm: Throw Performance Test:totalTime=6.928553ms throwTime=5.908972ms createErrorTime=1.019581ms Throw Performance Test:totalTime=1.357407ms throwTime=797.797us createErrorTime=559.61us Throw Performance Test:totalTime=1.215410ms throwTime=649.083us createErrorTime=566.327us Throw Performance Test:totalTime=1.023574ms throwTime=528.187us createErrorTime=495.387us Throw Performance Test:totalTime=973.957us throwTime=488.259us createErrorTime=485.698us Throw Performance Test:totalTime=943.841us throwTime=456.6us createErrorTime=487.241us Throw Performance Test:totalTime=940.144us throwTime=455.628us createErrorTime=484.516us Throw Performance Test:totalTime=954.059us throwTime=454.954us createErrorTime=499.105us Throw Performance Test:totalTime=954.739us throwTime=464.041us createErrorTime=490.698us Throw Performance Test:totalTime=953.431us throwTime=461.697us createErrorTime=491.734us Throw Performance Test:totalTime=946.232us throwTime=456.769us createErrorTime=489.463us Throw Performance Test:totalTime=962.239us throwTime=454.854us createErrorTime=507.385us Throw Performance Test:totalTime=957.696us throwTime=460.617us createErrorTime=497.079us Throw Performance Test:totalTime=956.284us throwTime=467.273us createErrorTime=489.011us Throw Performance Test:totalTime=954.624us throwTime=473.158us createErrorTime=481.466us Throw Performance Test:totalTime=952.835us throwTime=458.23us createErrorTime=494.605us Throw Performance Test:totalTime=936.177us throwTime=454.877us createErrorTime=481.3us Throw Performance Test:totalTime=936.955us throwTime=453.158us createErrorTime=483.797us Throw Performance Test:totalTime=952.953us throwTime=454.16us createErrorTime=498.793us Throw Performance Test:totalTime=932.074us throwTime=455.823us createErrorTime=476.251us Logs on Native:
    Task :runReleaseExecutableNative
    Throw Performance Test:totalTime=6.699028ms throwTime=6.183869ms createErrorTime=515.159us Throw Performance Test:totalTime=7.806001ms throwTime=7.431287ms createErrorTime=374.714us Throw Performance Test:totalTime=6.487319ms throwTime=6.302656ms createErrorTime=184.663us Throw Performance Test:totalTime=6.939379ms throwTime=6.678405ms createErrorTime=260.974us Throw Performance Test:totalTime=6.550303ms throwTime=6.358103ms createErrorTime=192.2us Throw Performance Test:totalTime=6.354265ms throwTime=6.186179ms createErrorTime=168.086us Throw Performance Test:totalTime=6.395004ms throwTime=6.207162ms createErrorTime=187.842us Throw Performance Test:totalTime=6.308159ms throwTime=6.150593ms createErrorTime=157.566us Throw Performance Test:totalTime=6.553794ms throwTime=6.305356ms createErrorTime=248.438us Throw Performance Test:totalTime=6.257863ms throwTime=6.143301ms createErrorTime=114.562us Throw Performance Test:totalTime=6.256012ms throwTime=6.142164ms createErrorTime=113.848us Throw Performance Test:totalTime=6.403581ms throwTime=6.276113ms createErrorTime=127.468us Throw Performance Test:totalTime=6.257133ms throwTime=6.143897ms createErrorTime=113.236us Throw Performance Test:totalTime=6.224807ms throwTime=6.125721ms createErrorTime=99.086us Throw Performance Test:totalTime=6.252487ms throwTime=6.156452ms createErrorTime=96.035us Throw Performance Test:totalTime=6.167458ms throwTime=6.074793ms createErrorTime=92.665us Throw Performance Test:totalTime=6.258211ms throwTime=6.110785ms createErrorTime=147.426us Throw Performance Test:totalTime=6.206690ms throwTime=6.109968ms createErrorTime=96.722us Throw Performance Test:totalTime=6.157968ms throwTime=6.066772ms createErrorTime=91.196us Throw Performance Test:totalTime=6.203606ms throwTime=6.106344ms createErrorTime=97.262us
    c
    m
    r
    • 4
    • 6
  • d

    Digory Doolittle

    12/16/2022, 5:13 PM
    Can someone help me out with this newbie question? https://stackoverflow.com/questions/74826174/pass-value-from-kotlin-native-to-c
  • d

    Daniel

    12/18/2022, 7:35 PM
    Error: Suspension functions can be called only within coroutine body for the code doing a remove and after a logout:
    suspend fun doLogout(token: String) {
        val userId = appService.currentUser?.id
    
            realm.write {
    
                var user = query<UserInfo>("_id = $0", userId).first().find()
                if (user != null) {
                    val productIndex =
                        user.FCMToken.withIndex().findLast { it.value == token }!!.index
    
                    user = findLatest(user)!!.also {
                        it.FCMToken.removeAt(productIndex)
                    }
                    copyToRealm(user)
    
                    appService.currentUser?.logOut() // Suspension functions can be called only within coroutine body
    
                }
            }
    }
    Is there anyway to fix this without changing much code? I need to do first the db operation then logOut()
    m
    m
    • 3
    • 15
  • j

    Joakim Forslund

    12/20/2022, 10:08 AM
    Why was the examples removed from the kotlin-native repo? I am not able to find any sort of interop examples on the new suggested link?
    m
    • 2
    • 4
  • j

    jun chen

    12/20/2022, 11:55 AM
    Kotlin/Native GC pause time up to 30 milliseconds Every Time,Is this GC time normal?
    • 1
    • 2
  • h

    hfhbd

    12/21/2022, 1:43 AM
    Did anybody create a Jvm from Kotlin/Native (C)? I get this error message:
    Error occurred during initialization of VM
    Failed setting boot class path.
    and don't know, if I did make a mistake in Kotlin.
    • 1
    • 1
  • d

    Dmitriy Tarasevich

    12/21/2022, 12:25 PM
    Hello 👋 I am trying to use a cocoapod in our multi module KM Project. I have all bindings showing up, but am two experiencing two seperate issues during compile time. 1. It seems as though the
    assemble<ProjectName>RelaseXCFramework
    does not automatically link the cocoapod frameworks into the build. for each architecture i have to manually specify the libraries cocoapod location using
    linkerOpts("-F$frameworkPath")
                            linkerOpts("-rpath", frameworkPath)
                            linkerOpts("-framework", "<Library>"
    Once i do this, i can get a successful build, but a failure once i utilize the framework in my project with the following errror
    dyld[32068]: Library not loaded: <FrameworkClass>
    I feel like I have an incorrect setting as no where in docs is it stated that i have to manually link cocoapod frameworks. Any suggestions?
    l
    • 2
    • 40
  • m

    marcinmoskala

    12/21/2022, 9:19 PM
    I am writing Advanced Kotlin book, where I present advanced aspects of Kotlin development, and as a part of that, I decided to present specificity of different flavors, including Kotlin/Native. Since I do not feel strong enough in this topic, I am looking for a person with experience with Kotlin/Native, who would want to write a guest chapter about practical aspects of using it. It does not need to be long, as long as it offers value for those preparing to use Kotlin/Native, or trying to understand what makes this platform different.
  • k

    kevin.cianfarini

    12/21/2022, 9:38 PM
    How would I specify a relative path when linking a static library within
    libraryPaths
    ?
    headers = foo.h
    staticLibraries = libfoo.a
    libraryPaths = /some/relative/path
    n
    • 2
    • 4
  • m

    Marco Dalla Bà

    12/22/2022, 11:20 AM
    Hi everyone, I don't know if this is the correct channel. I'm working on a kmm project (Kotlin 1.7.0, kotlin.native.binary.memoryModel=experimental) and I have an IPWebSocket class.
    class IPWebSocket() {//...
    	private val requestQueue: MutableList<IPMessageRequest> = mutableListOf()
    	//...
    
    	fun send(request: IPMessageRequest) {
    		requestQueue.add(request)
    		webSocket.sendMessage(request)
    		scope.launch {
                delay(REQUEST_TIMEOUT)
                requestQueue.firstOrNull { it == request }?.let {
                    //Some operations
                }
            }
    	}
    	//...
    	fun receive(msg: Message) {
    		val iterator = requestQueue.listIterator()
            while (iterator.hasNext()) {
                val request = iterator.next()
                if (msg.msgid == request.msgid) {
                    iterator.remove()
                }
            }
    	}
    }
    With the new Native Memory Management, by reading the docs, I understood that I don't need to handle locks on the requestQueue like I was doing before with stately-iso-collection but I'm still getting ConcurrentModificationException on the send function. What I am doing wrong? Note: obviously the send and receive methods can be accessed by multiple threads EDIT: ok I think I found the problem, we're using kotlin.coroutines "1.6.0-native-mt" and -native-mt should be removed. But I think the app will slow down If I do that.
    m
    p
    • 3
    • 7
  • h

    hfhbd

    12/22/2022, 3:19 PM
    JNI again: How do you write this cpp code in Kotlin?
    JNIEnv *env;
    JNI_CreateJavaVM(&jvm, (void**)&env, &vm_args);
    I tried this but always get the error, the env is null:
    memScope {
      val env = alloc<JNIEnvVar>().ptr
      JNI_CreateJavaVM(jvm, env.reinterpret(), vmArgs.ptr)
      env.pointed.pointed!!.GetVersion!!(env) // GetVersion!! was null
    }
    `
    So I guess there is an error with converting the env to
    (void**)
    https://docs.oracle.com/javase/7/docs/technotes/guides/jni/spec/invocation.html https://github.com/hfhbd/jniTest/blob/deferWorkaround/src/nativeMain/kotlin/Foo.kt
    d
    • 2
    • 3
  • k

    kevin.cianfarini

    12/22/2022, 6:30 PM
    If I have a c function that takes a struct pointer and populates that reference with a value:
    struct Foo foo;
    init_too(&foo)
    return foo
    Is this the right way to perform the same task using cinterop?
    val foo = Foo(NativePtr.NULL)
    init_foo(foo.ptr)
    return foo
    l
    • 2
    • 11
  • e

    Eric Womer

    12/23/2022, 12:49 AM
    Is there a way to get the name of a variable and print it out or store it as a string?
    s
    • 2
    • 2
  • k

    kevin.cianfarini

    12/23/2022, 4:36 AM
    I need to pass a
    ByteArray
    buffer from Kotlin to C so that it can be written to. The underlying lib expects it in the form of an
    iovec
    . Do I have to have
    StableRef
    to do this?
    iovec.iov_base
    is expecting the buffer in the form of a
    COpaquePointer
    .
    n
    • 2
    • 5
  • d

    Digory Doolittle

    12/26/2022, 10:59 AM
    I started a VST3 virtual instrument plugin in Kotlin/native. Unfortunately, I'm facing major performance issues. The DAW's CPU usage indicator clearly shows my plugin uses way too much CPU. Even though some of my code could be optimised a bit (e.g. lookup tables instead of computing all waveforms ad hoc), I'm baffled at how much CPU the plugin is using while still a lot of the features haven't even been implemented yet. I suspect Kotlin/native's memory management might be the problem, because there are bursts of performance drops that might be caused by the GC. I tried to avoid creating unnecessary objects, even avoiding lambdas and iterators. I'm a bit at a loss what I could try next. Any suggestions? If you want to have a look at the source code, here's the Github project: https://github.com/digorydoo/kangaroo The core is in /src/nativeMain/kotlin/ch/digorydoo/kangaroo/audio/AudioProcessor.kt, onProcessBlock.
  • k

    kevin.cianfarini

    12/27/2022, 4:07 PM
    I'm confused on the difference between the following two pieces of code. For context, I need to pass a pointer to String to a C function and have that memory be valid after the current function call pops off the stack. To do that, the cinterop guide mentions allocating the c string in native memory using
    val cstring = "some string".cstr.getPointer(nativeHeap)
    This produces a pointer to valid memory. However, why does this function any differently than
    val pinnedCstr = "some string".cstr.pin()
    I want to manually unpin this value and avoid the copy if I can. This memory is no longer valid once it's accessed from the C library I'm interfacing with and I don't understand why
  • k

    kevin.cianfarini

    12/27/2022, 5:19 PM
    I have a more generalized question related to the above question. Since KMP is going to go stable soon, can we expect more robust documentation of cinterop? Right now things are very vague and pretty inconsistent. For example,
    AutofreeScope
    and
    Arena
    have absolutely no documentation. The examples of Kotlin and C String interop are inconsistent in their usage of
    getPointer
    or not. This leads to a lot of trial and error for people consuming non-trivial C libraries.
  • k

    kevin.cianfarini

    12/27/2022, 11:34 PM
    How do I get a pointer to the first element in an
    Array<SomeCStruct>
    ? I'm using it with the
    iovec
    struct for
    readv
    system calls. All of the
    addressOf
    calls seems to be implemented only for primitive array types like
    ByteArray
    and
    String
    . The
    readv
    syscall expects a
    CValuesRef<iovec>
    as a parameter which I am struggling to conjure.
    • 1
    • 1
Powered by Linen
Title
k

kevin.cianfarini

12/27/2022, 11:34 PM
How do I get a pointer to the first element in an
Array<SomeCStruct>
? I'm using it with the
iovec
struct for
readv
system calls. All of the
addressOf
calls seems to be implemented only for primitive array types like
ByteArray
and
String
. The
readv
syscall expects a
CValuesRef<iovec>
as a parameter which I am struggling to conjure.
🤦‍♂️ nevermind, I think I want a
Placement.allocArray
View count: 35