How to create Kotlin Lambda form C

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.

I don’t know the answer, but I think the answer is either “you can’t”, or “it’s going to be very hard”. A quick web search reveals that C does not support lambdas, and doesn’t really support inheritance.

My thinking would be that you have to create an instance of the struct with a function that does what you want, but I can’t even remember if C structs can hold functions, or only values… I think they only hold values. So it might not be possible.