Skip to content
This repository has been archived by the owner on Aug 10, 2021. It is now read-only.

error: unknown type name 'libtestlib_kref_kotlin_IntArray #3890

Closed
algidrus opened this issue Feb 19, 2020 · 4 comments
Closed

error: unknown type name 'libtestlib_kref_kotlin_IntArray #3890

algidrus opened this issue Feb 19, 2020 · 4 comments

Comments

@algidrus
Copy link

algidrus commented Feb 19, 2020

I've tried to build static/dynamic libs for iOS/Android, but "unknown type name 'libtestlib_kref_kotlin_IntArray" error occurs.
If I build an executable file for MacOS it compiles and works fine without any errors.
How can I treat it?

OS: MacOS, kotlin 1.3.61

Full code of my sample:
//******************************************
package test

import kotlin.text.*
import kotlin.native.concurrent.*

fun findSum(br: ByteArray): Double {
var sum: Double = 0.0
for (i in 0..br.lastIndex) {
sum+=br[i].toDouble()
}
return sum
}

fun findSum(br: UByteArray): Double {
var sum: Double = 0.0
for (i in 0..br.lastIndex) {
sum+=br[i].toDouble()
}
return sum
}

fun findSum(br: UIntArray): Double {
var sum: Double = 0.0
for (i in 0..br.lastIndex) {
sum+=br[i].toDouble()
}
return sum
}

@kotlin.ExperimentalStdlibApi
fun main(args: Array)
{
var sum = 0.0
val arr_b = byteArrayOf(10.toByte(),
20.toByte(),
30.toByte(),
40.toByte(),
50.toByte(),
60.toByte(),
70.toByte(),
80.toByte(),
90.toByte())

sum = findSum(arr_b)
println("Sum = $sum")


val arr_ub = ubyteArrayOf(10.toUByte(),
                      20.toUByte(),
                      30.toUByte(),
                      40.toUByte(),
                      50.toUByte(),
                      60.toUByte(),
                      70.toUByte(),
                      80.toUByte(),
                      90.toUByte())

sum = findSum(arr_ub)
println("Sum = $sum")


val arr_ui = uintArrayOf(10.toUInt(),
                      20.toUInt(),
                      30.toUInt(),
                      40.toUInt(),
                      50.toUInt(),
                      60.toUInt(),
                      70.toUInt(),
                      80.toUInt(),
                      90.toUInt())

sum = findSum(arr_ui)
println("Sum = $sum")

}

@artdfel
Copy link
Contributor

artdfel commented Feb 20, 2020

Hello, @algidrus! Thank you for the report, seems like this is a bug.
The problem here is that, for some reason, UIntArray presence in your case did not lead to an appropriate typedef declaration in the produced library header. This can be reproduced with any primitive unsigned-type array. For signed-type ones, everything works correctly - even in your case, this is the reason why only IntArray failed - because of the first function, libtestlib_kref_kotlin_ByteArray typedef was generated correctly.
To workaround this issue, I would recommend exposing all primitive type arrays explicitly - for example, just add a top-level val regIntArray = intArrayof().
And this is working correctly for Mac because of executables have no headers. If you'll try to build a library, it will fail the same way, I checked 🙂.

@algidrus
Copy link
Author

Thanks a lot)
I hope it will be fixed in the next version ;)

@artdfel
Copy link
Contributor

artdfel commented May 21, 2020

YouTrack ticket on this issue's causes: https://youtrack.jetbrains.com/issue/KT-36878.

@SvyatoslavScherbina
Copy link
Collaborator

According to migrating issue tracking to YouTrack, closing this issue in favour of https://youtrack.jetbrains.com/issue/KT-36878

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants