[luabind] attempt to concatenate field 'value' (a function value)
Brought to you by:
arvidn,
daniel_wallin
From: <ma...@sq...> - 2014-11-01 17:59:31
|
Can anybody explain this for me? It used to work on an older system with lua5.1. i'm now using lua5.2, luabind version us 0.9.1 (on both systems) g++ -o lua lua.cpp -lluabind -llua5.2 -ldl -I /usr/include/lua5.2 ./lua lua runtime error [string "function test(t)..."]:2: attempt to concatenate field 'value' (a function value) extern "C" { #include "lua.h" #include "lualib.h" #include "lauxlib.h" } #include <luabind/luabind.hpp> #include <iostream> struct Test { Test(int v) : value(v) {}; ~Test() {}; int value; }; int DebuggerFunc(lua_State* L) { luabind::object error_msg(luabind::from_stack(L, -1)); std::cerr << error_msg << std::endl; return 0; } int main() { lua_State *L = luaL_newstate(); luabind::open(L); luabind::module(L) [ luabind::class_<Test>("Test") .def(luabind::constructor<int>()) .def_readonly("value",&Test::value) ]; luaL_dostring( L, "function test(t)\n" " print(\"value : \" .. t.value)\n" "end\n" ); Test t(4); try { luabind::call_function<int>(L, "test", &t); } catch (const luabind::error &er) { std::cerr << er.what() << std::endl; lua_State* Ler=er.state(); DebuggerFunc(Ler); } catch (...) { std::cerr << "Unknown error!" << std::endl; } lua_close(L); } |