C++ Luabind编译时错误无法推断模板参数
我得到了一个我不理解的编译时错误列表。我正在使用sourceforge版本0.9.1中的luabind库,并尝试绑定MyGUI中的函数,我正在使用Visual Studio 2012和Lua 5.1。这些错误出现在下面的cpp代码的编译过程中,尽管看起来源于其他文件。这些错误让我觉得我没有在某个地方正确定义签名,但是我的IntelliSense没有指出任何此类问题 有关守则: (Stackoverflow抱怨身体的长度,所以我把它放在了pastebin上) 给出的错误如下:C++ Luabind编译时错误无法推断模板参数,c++,visual-studio-2012,lua,luabind,C++,Visual Studio 2012,Lua,Luabind,我得到了一个我不理解的编译时错误列表。我正在使用sourceforge版本0.9.1中的luabind库,并尝试绑定MyGUI中的函数,我正在使用Visual Studio 2012和Lua 5.1。这些错误出现在下面的cpp代码的编译过程中,尽管看起来源于其他文件。这些错误让我觉得我没有在某个地方正确定义签名,但是我的IntelliSense没有指出任何此类问题 有关守则: (Stackoverflow抱怨身体的长度,所以我把它放在了pastebin上) 给出的错误如下: Error 4
Error 4 error C2780: 'void luabind::detail::value_wrapper_converter<U>::apply(lua_State *,const T &)' : expects 2 arguments - 3 provided c:\users\jake kiesel\space-junk\c++ project\3rdpartycode\include\luabind\detail\call.hpp 293 1 Space Junk
Error 3 error C2784: 'int luabind::detail::value_wrapper_converter<U>::match(lua_State *,luabind::detail::by_const_reference<T>,int)' : could not deduce template argument for 'luabind::detail::by_const_reference<T>' from 'luabind::detail::by_reference<T>' c:\users\jake kiesel\space-junk\c++ project\3rdpartycode\include\boost\preprocessor\iteration\detail\local.hpp 34 1 Space Junk
Error 2 error C2784: 'int luabind::detail::value_wrapper_converter<U>::match(lua_State *,luabind::detail::by_value<T>,int)' : could not deduce template argument for 'luabind::detail::by_value<T>' from 'luabind::detail::by_reference<T>' c:\users\jake kiesel\space-junk\c++ project\3rdpartycode\include\boost\preprocessor\iteration\detail\local.hpp 34 1 Space Junk
Error 6 error C2784: 'T luabind::detail::value_wrapper_converter<U>::apply(lua_State *,luabind::detail::by_const_reference<T>,int)' : could not deduce template argument for 'luabind::detail::by_const_reference<T>' from 'luabind::detail::by_reference<T>' c:\users\jake kiesel\space-junk\c++ project\3rdpartycode\include\luabind\detail\call.hpp 293 1 Space Junk
Error 5 error C2784: 'T luabind::detail::value_wrapper_converter<U>::apply(lua_State *,luabind::detail::by_value<T>,int)' : could not deduce template argument for 'luabind::detail::by_value<T>' from 'luabind::detail::by_reference<T>' c:\users\jake kiesel\space-junk\c++ project\3rdpartycode\include\luabind\detail\call.hpp 293 1 Space Junk
Error 4 Error C2780:'void luabind::detail::value\u wrapper\u converter::apply(lua\u State*,const T&'):需要2个参数-3个提供的参数c:\users\jake kiesel\space junk\c++project\3rdpartycode\include\luabind\detail\call.hpp 293 1 space junk
错误3错误C2784:'int luabind::detail::value\u wrapper\u converter::match(lua\u State*,luabind::detail::by\u const\u reference,int)“:无法从“luabind::detail::by_reference”c:\users\jake kiesel\space junk\c++project\3rdpartycode\include\boost\preprocessor\iteration\detail\local.hpp 34 1 space junk”推断“luabind::detail::by_const_reference”的模板参数
错误2错误C2784:'int luabind::detail::value\u wrapper\u converter::match(lua\u State*,luabind::detail::by\u value,int)“:无法从“luabind::detail::by_reference”c:\users\jake kiesel\space junk\c++project\3rdpartycode\include\boost\preprocessor\iteration\detail\local.hpp 34 1 space junk中推断出“luabind::detail::by_value”的模板参数
错误6错误C2784:'T luabind::detail::value\u wrapper\u converter::apply(lua\u State*,luabind::detail::by\u const\u reference,int)“:无法从“luabind::detail::by_reference”c:\users\jake kiesel\space junk\c++project\3rdpartycode\include\luabind\detail\call.hpp 293 1 space junk”推断“luabind::detail::by_const_reference”的模板参数
错误5错误C2784:'T luabind::detail::value\u wrapper\u converter::apply(lua\u State*,luabind::detail::by\u value,int)':无法从'luabind::detail::by\u reference'c:\users\jake kiesel\space junk\c++project\3rdpartycode\include\luabind\detail\call.hpp 293 1 space junk'中推断出'luabind::detail::by\n'的模板参数
编辑:
通过进一步研究,我发现以下是引发这些错误的问题。这些行位于wrapGuiManager函数中
luabind::def(“destroyWidgets”&MyGUIManager::destroyWidgets)
luabind::def(“unloadLayout”&MyGUIManager::unloadLayout)
以下是这些函数的函数声明:
void布局(luabind::对象和表)
void销毁小部件(luabind::对象和表)
这两个函数都是唯一的,因为它们采用luabind::object&参数。他们应该能够从Lua获取一个表,该表用作一个充满MyGUI小部件的数组。我让它工作了!:D问题线路是
luabind::def("destroyWidgets", &MyGUIManager::destroyWidgets)
及
这两个函数都采用了luabind::object&
,但luabind不想与它们合作,而是希望函数采用luabind::object
,而不使用引用,只使用对象本身。因此,正确的函数声明应该是:
void unloadLayout(luabind::object table);
void destroyWidgets(luabind::object table);
我会尝试一次导出一个类和函数,直到您找到导致错误的原因。如果这个文件相当大,我真的很想避免这种情况,但这似乎是目前唯一的解决方案。使用这种方法,我能够将问题隔离到wrapGuiManager函数。将继续研究此函数。是否也可以发布MyGUIManager::destroyWidgets和MyGUIManager::unloadLayout的函数声明?完成。顺便说一句,谢谢你一直陪着我。
void unloadLayout(luabind::object table);
void destroyWidgets(luabind::object table);