【发布时间】:2014-07-16 04:32:45
【问题描述】:
我无法让它工作。
这是我的代码,我尽量保持简单:
#include <iostream>
#include <lua/lua.hpp>
#include <luabind/luabind.hpp>
#include <luabind/class.hpp>
class MyClass
{
public:
MyClass() {}
~MyClass() {}
void myFunc() { std::cout << "Hi !" << std::endl; }
int getMyVar2() { return (this->myVar2); }
int myVar;
private:
int myVar2;
};
int main()
{
MyClass *m = new MyClass();
lua_State *L = luaL_newstate();
luabind::open(L);
luabind::module(L)
[
luabind::class_<MyClass>("MyClass")
.def("myFunc", &MyClass::myFunc)
.def("getMyVar2", &MyClass::getMyVar2)
.def("myVar", &MyClass::myVar)
];
luabind::globals(L)["globalName"] = m;
if (luaL_dofile(L, "example.lua"))
fprintf(stderr, "%s\n", lua_tostring(L, -1));
lua_close(L);
}
编译器给了我很多垃圾信息,通过重定向输出,我首先看到了:
/usr/local/include/luabind/class.hpp: In instantiation of ‘void luabind::detail::memfun_registration<Class, F, Policies>::register_(lua_State*) const [with Class = MyClass; F = int MyClass::*; Policies = luabind::detail::null_type; lua_State = lua_State]’:
exemple_luabind.cpp:48:1: required from here
/usr/local/include/luabind/class.hpp:311:52: error: no matching function for call to ‘deduce_signature(int MyClass::* const&, MyClass*)’
第 48 行是:
}
谁能帮帮我?我确定这是初学者的错误..
【问题讨论】: