Basically I don't know how to do something like that:
    lua_pushcfunction(L, int func(lua_State* L) { 
      printf("hello");
      return 0;
    });
I have tried many stuff but doesnt just work
Basically I don't know how to do something like that:
    lua_pushcfunction(L, int func(lua_State* L) { 
      printf("hello");
      return 0;
    });
I have tried many stuff but doesnt just work
Two ways:
Define the function then push it.
int func(lua_State* L) { 
  printf("hello");
  return 0;
};
// later...
lua_pushcfunction(L, func);
This is the only way you could do it in C, or before C++11.
Use a lambda expression (aka. anonymous function):
lua_pushcfunction(L, [](lua_State* L) -> int { 
  printf("hello");
  return 0;
});
