how to correctly call the function: ```@kotlinx.c...
# kotlin-native
m
how to correctly call the function:
Copy code
@kotlinx.cinterop.internal.CCall public external fun SCNetworkReachabilityGetFlags(target: platform.SystemConfiguration.SCNetworkReachabilityRef? /* = kotlinx.cinterop.CPointer<cnames.structs.__SCNetworkReachability>? */, flags: kotlinx.cinterop.CValuesRef<platform.SystemConfiguration.SCNetworkReachabilityFlagsVar /* = kotlinx.cinterop.UIntVarOf<kotlin.UInt> */>?): kotlin.Boolean { /* compiled code */ }
to receive the 
kSCNetworkReachabilityFlags…
 correctly? in Swift, we can make the call:
Copy code
var flags: SCNetworkReachabilityFlags = []
if !SCNetworkReachabilityGetFlags(defaultRouteReachability, &flags) {
    return false
}
And receive the flags in an array style…. In Kotlin Native, I am doing:
Copy code
// val flags = allocArray<SCNetworkReachabilityFlagsVar>(10) // -> this was my first attempt, they are 10 possible flags!
val flags = alloc<SCNetworkReachabilityFlagsVar>()

if (!SCNetworkReachabilityGetFlags(reachabilityRef, flags.ptr)) return false
the problem is I am receiving all the flag “summed” (they are 
kotlin.UInt
), and not split in an array, like in Swift.
r
Try
allocArrayOf()
m
@russhwolf the
allocArrayOf()
needs a
vargarg
as a parameter, how could I use it?
a
Hello, @magnumrocha! I’ve found an example here, thanks to the thread. Please take a look.
👍 1
m
thanks @Artyom Degtyarev [JB] 👍 I’m using it right this way