我有这个必须匹配的函数签名
typedef int (*lua_CFunction) (lua_State *L);//target sig
这是我到目前为止所拥有的:
//somewhere else...
...
registerFunction<LuaEngine>("testFunc", &LuaEngine::testFunc, this);
...
//0 arg callback
void funcCallback0(boost::function<void ()> func, lua_State *state)
{
func();
}
template<typename SelfType>
void registerFunction(const std::string &funcName, boost::function<void (SelfType*)> func, SelfType *self)
{
//funcToCall has to match lua_CFunction
boost::function<void (lua_State *)> funcToCall = boost::bind(&LuaEngine::funcCallback0, this,
boost::bind(func, self), _1);
lua_register(_luaState, funcName.c_str(), funcToCall);
}
但是,在lua_register(_luaState...
,它仍然在抱怨转换问题
错误 1 错误 C2664: 'lua_pushcclosure' : 无法将参数 2 从 'boost::function' 转换为 'lua_CFunction'
有谁知道如何解决这个问题?