Hi, in my Kotlin/native project ``` ..... var outp...
# kotlin-native
v
Hi, in my Kotlin/native project
Copy code
.....
var outputLength = cValuesOf(0)
......
val outputBA = outputData.readBytes(outputLength convert int)
How to Convert outputLength to Int Thanks
d
outputLength[0].toInt()
?
c
better to use
convert()
it deals with platform specific length of native type like int 32 or int 64:
val outputBA = outputData.readBytes(outputLength.convert())
And there is no overhead since this is resolved at compilation time if I remember properly.
Actually depending on what you are using inside your
cvalueOf()
you can use this straight away with
convert()
. Instead of:
Copy code
.....
var outputLength = cValuesOf(myLength)
......
val outputBA = outputData.readBytes(outputLength convert int)
you can perhaps try :
Copy code
......
val outputBA = outputData.readBytes(myLength.convert())
👍 1