Hello! I’m checking cinterop tool documentation a...
# kotlin-native
d
Hello! I’m checking cinterop tool documentation and saw next statement: “Also, any C type has the Kotlin type representing the lvalue of this type, i.e., the value located in memory rather than a simple immutable self-contained value. Think C++ references, as a similar concept. For structs (and typedefs to structs) this representation is the main one and has the same name as the struct itself, for Kotlin enums it is named ${type}Var, for CPointerT it is CPointerVarT, and for most other types it is ${type}Var. For types that have both representations, the one with a “lvalue” has a mutable .value property for accessing the value.” Could somebody explain me please, as I worked a long time ago with plain C. Thank you
e
3
is an rvalue, you cannot
&3
or
3 = y
int x = 3; x
is an lvalue, you can
&x
or
x = y
say for example you have a
struct Foo { int x; }
in C the type
Foo
behaves more like a
struct Foo&
in C++ (which is like a
struct Foo*
in C, but guaranteed non-null)
d
@ephemient , thank you for the reply. I didn’t get want kind of representations are in Kotlin for C types. What does it mean “C++ has similar concept”?And what are “types that have both representations”? Thank you!
e
types that have both include things like `Int`/`IntVar`
d
Thank you, now I got regarding both representations
I still couldn’t get something similar with C++
What does it mean? “the type
Foo
behaves more like a
struct Foo&
in C++ (which is like a
struct Foo*
in C, but guaranteed non-null)”?Maybe I’m a little bit slow)
Thank you for your help