I’m trying to call kotlin(Native) function in C code, this is my kotlin function :
object LambdaTest {
var configA = 0
var configB = ""
fun config(block: LambdaTest.() -> Unit) {
this.block()
}
}
I compiled it as a static library by kotlinc-native, I got a C header file that is static_api.h and libstatic.a library.
this is some code of static_api.h
:
typedef struct {
static_KNativePtr pinned;
} static_kref_kotlin_Function1;
/* User functions. */
struct {
struct {
struct {
// Unrelated code has been deleted......
void (*config)(static_kref_LambdaTest thiz, static_kref_kotlin_Function1 block);
} LambdaTest;
} root;
} kotlin;
} static_ExportedSymbols;
extern static_ExportedSymbols* static_symbols(void);
My question is how to build static_kref_kotlin_Function1
in C code? static_kref_kotlin_Function1
corresponds to the lambda parameter of the config
function in Kotlin.