我想我找到了答案,很快就会返回结果
我收到此错误并且不知道如何在方法不是静态的情况下修复它。如果它们是静态的,我不会收到错误消息,但是我无法使用我的任何非静态变量或函数。另外,在您说 int 和 lua_CFunction 可能是不同的类型之前,它们不是。这是 lua_CFunction 的定义方式
typedef int (*lua_CFunction) (lua_State *L);
*
1 IntelliSense: argument of type "int (LuckyIrc::*)(lua_State *l)" is incompatible with parameter of type "lua_CFunction" f:\Programming\Visual Studio\C++\IrcBot\IrcBot\LuckyIrc.h 129 4 IrcBot
代码:
class MyClass{
//other stuff
private:
//other stuff
int Lua_SendMessage(lua_State *l);
int Lua_SendRaw(lua_State *l);
int Lua_SendAction(lua_State *l);
int Lua_SendNotice(lua_State *l);
int Lua_Quit(lua_State *l);
int Lua_Part(lua_State *l);
int Lua_SendNick(lua_State *l);
int Lua_Kick(lua_State *l);
int Lua_Join(lua_State *l);
int Lua_Connect(lua_State *l);
void SetUpLua()
{
LuaState = luaL_newstate();
luaL_openlibs(LuaState);
/*Error happens here*/lua_register(LuaState, "SendMessage", Lua_SendMessage);
/*And here*/lua_register(LuaState, "SendRaw", Lua_SendRaw);
/*And here*/lua_register(LuaState, "Quit", Lua_Quit);
/*And here*/llua_register(LuaState, "Part", Lua_Part);
/*And here*/lua_register(LuaState, "SendNotice", Lua_SendNotice);
/*And here*/lua_register(LuaState, "SendAction", Lua_SendAction);
/*And here*/llua_register(LuaState, "SetNick", Lua_SendNick);
/*And here*/llua_register(LuaState, "Join", Lua_Join);
/*And here*/llua_register(LuaState, "Kick", Lua_Kick);
/*And here*/llua_register(LuaState, "Connect", Lua_Connect);
}
}