Could someone please explain me the difference bet...
# kotlin-native
p
Could someone please explain me the difference between CPointer and CPointerVar? I have been struggling to understand the difference, but haven't been able to make any headway
d
The latter is like a C++ reference. The former is a value.
n
Another way to look at it is that CPointer points to something that is immutable (kind of like Kotlin's val), where as CPointerVar points to something that is mutable (kind of like Kotlin's var).
p
Interesting 🤔 Okay thanks I'll have to ponder on it some more
r
CPointer
is a pointer to a value (
int* p
in c) while
CPointerVar
is a pointer to a pointer (
int** p
in c). I don't think immutability/mutability apply here.
👍 3
n
Had mistaken CPointer for CValuesRef, which holds immutable values in an array ( https://kotlinlang.org/docs/reference/native/c_interop.html#passing-pointers-to-bindings ).
p
That makes a lot more sense 😄 thanks guys