Luabind: "No matching overload found, candidates:"
Note, I have read and applied the answer to: Calling C++ member function from Luabind causes "No matching overload found", but this did not solve my issue.
I have a simple class that I expose to LUA via luabind
Here is the binding code:
void LogManager::luaBindImpl() const
{
using namespace luabind;
lua_State* state(Supervisor::getSingleton().getManager<LuaManager>()->state());
// LogManager
module(state)
[
class_<LogManager>("LogManager")
.enum_("LogType")
[
value("Info", 1)
,value("Warning", 2)
,value("Critical", 3)
,value("Debug", 4)
]
.def("log", &LogManager::log)
.def("registerSource", &LogManager::registerSource)
];
// Add to globals
globals(state)["LogManager"] = this;
}; // eo luaBindImpl
And here is my LUA:
LogManager.registerSource("lol");
But I get the error mentioned in the title (this taken straight from my log file):
00:00:00:0520- lua:Exception - No m开发者_JAVA技巧atching overload found, candidates:
void registerSource(LogManager&,std::string const&)
I've been tearing my hair out over this and can't see what I am doing wrong. Can anyone shed any light?! :)
In the Lua part, you need to use colon (:
) instead of a dot:
LogManager:registerSource("lol");
And you do realize the global variable LogManager
has the same name with the class LogManager
; that way you won't be able to use the enum constants, e.g. LogManager.Info
will return nil.
精彩评论