Lua と C++ のインターフェースの基本を学ぼうとしていますが、問題が発生しました。文字列を返す関数を呼び出して、C++ 側で文字列を操作したいのですが、luaL_dostring が Lua スタックに何も置かないようです。
簡単なテストでさえ、正しく動作していないようです:
lua_State* lua = lua_open();
luaL_openlibs(lua);
//Test dostring.
luaL_dostring(lua, "return 'derp'");
int top = lua_gettop(lua);
cout << "stack top is " <<top << endl;
//Next, test pushstring.
lua_pushstring(lua, "derp");
top = lua_gettop(lua);
cout << "stack top is " << top << endl;
出力:
stack top is 0
stack top is 1
何か案は?