I still don’t understand the types of kotlin nativ...
# kotlin-native
p
I still don’t understand the types of kotlin native. According to this table https://github.com/JetBrains/kotlin/blob/06498c0efdb218da4bd1b09b6ae0b98beb8b7af9/native/utils/src/org/jetbrains/kotlin/konan/target/KonanTarget.kt
Copy code
...
    object WATCHOS_ARM32 : KonanTarget("watchos_arm32", Family.WATCHOS, Architecture.ARM32)
    object WATCHOS_ARM64 : KonanTarget("watchos_arm64", Family.WATCHOS, Architecture.ARM64)
...
And this https://github.com/JetBrains/kotlin/blob/06498c0efdb218da4bd1b09b6ae0b98beb8b7af9/native/utils/src/org/jetbrains/kotlin/konan/target/Architecture.kt
Copy code
enum class Architecture(val bitness: Int) {
 ...
    ARM64(64),
    ARM32(32)
,...
}
watchosarm32 is 32 bit and watchosarm64 is 64 bit. However when I now take a look at my
watchosArm32Main
source set, for example
NSDateComponents
have `NSInteger`s which will be interpreted as kotlin ints. Makes sense to me. Now however in
watchosArm64Main
it’s also an Int. Why is that? Why isn’t this now a
Long
? Apparently all ios source sets have longs, all watchos source sets have ints. I thought this is dependent on the bitness?
s
Because watchOS ARM64 is a bit, let's call it, "special". When Apple introduced Apple Watch Series 4 they wanted to do two things: 1. Have a 64-bit processor 2. Port existing 32-bit apps using bitcode recompilation on their servers. (Personally, I think it's a strange solution, but I'm not a decision-maker at Apple ¯\_(ツ)_/¯) So they introduced a special architecture, `arm64_32`: long and pointer types are 32-bit wide there unlike usual ARM64 ABI. That's why you see
Int
instead of
Long
on
watchosArm64
.
p
Thanks 👍 This is so strange to understand. I was trying to create intermediate source sets to handle all the long / bit magic