我试图从我在Lua中使用的库中包装一个类。特别是,我试图从SFML中包装颜色类。颜色等级的完整来源可见here和here。呼叫运营商没有匹配的功能新
这是这是我在我失败的功能。
int SFColor_new(lua_State* L)
{
// omitting part where I set r, g, b, and a
new (lua_newuserdata(L, sizeof(Color))) Color(r, g, b, a); // Line 47
luaL_getmetatable(L, LuaInfo<Color>::myMetaTableName);
lua_setmetatable(L, -2);
return 1;
}
这是错误
LuaSFMLColor.cpp: In function ‘int ag::SFColor_new(lua_State*)’:
LuaSFMLColor.cpp:47: error: no matching function for call to ‘operator new(unsigned int, void*)’
<built-in>:0: note: candidates are: void* operator new(unsigned int)
make: *** [game] Error 1
我做一些其他地方类似的事情而不会遇到这个错误,所以我不确定会是什么原因造成的。看着Color的源代码,我没有看到任何奇怪或不寻常的东西,而且我已经没有想法。我也尝试过使用默认的构造函数(即没有参数),然后只是设置值,但也没有做任何好处。
这与Lua无关。 – lhf 2010-07-01 11:52:23
我当时不知道。 :P – Alex 2010-07-02 00:40:25