小编Cob*_*bra的帖子

在Lua中注册C++函数?

我想在Lua中注册一个c ++函数.

但是得到这个错误:

CScript.cpp|39|error: argument of type 'int (CScript::)(lua_State*)' does not match 'int (*)(lua_State*)'|
Run Code Online (Sandbox Code Playgroud)

编辑:

int CApp::SetDisplayMode(int Width, int Height, int Depth)
{
    this->Screen_Width = Width;
    this->Screen_Height = Height;
    this->Screen_Depth = Depth;

    return 0;
}

int CScript::Lua_SetDisplayMode(lua_State* L)
{
  // We need at least one parameter
  int n = lua_gettop(L);
  if(n < 0)
  {
    lua_pushstring(L, "Not enough parameter.");
    lua_error(L);
  }

  int width = lua_tointeger(L, 1);
  int height = lua_tointeger(L, 2);
  int depth = lua_tointeger(L, 3);

  lua_pushinteger(L, App->SetDisplayMode(width, height, depth));

  return …
Run Code Online (Sandbox Code Playgroud)

c++ lua

1
推荐指数
2
解决办法
6179
查看次数

标签 统计

c++ ×1

lua ×1