如何跟蹤我的編譯順序? (以便我可以重新排序)瞭解編譯順序,編譯錯誤和由於基類導致的luabind undefined
我的問題: 我正在運行Visual Studio 2012編寫C++應用程序。我綁定一個腳本系統,Lua中,使用LuaBind
LuaBind我的項目隱藏了Lua的東西,並計算出如何將其綁定到Lua語言(或一些魔術)
我可以把一個對象,調用它的功能,並傳遞一個C++對象被賦予LUA腳本函數
// ScriptComponent.h
class ScriptComponent : public Component
{
public:
virtual void Initialize();
virtual void Update();
protected:
luabind::object luaDataTable;
Entity* mOwner;
-
// ScriptComponent.cpp
void ScriptComponent::Initialize() {
luabind::object compiledScript;
luaL_loadfile(L, "myScript.lua");
luabind::object compiledScript(luabind::from_stack(L, -1));
luaDataTable = compiledScript();
lua_pop(L, 1);
}
void ScriptComponent::Update() {
luaDataTable["run"](mOwner); // Compiler breaks here.
// Note: if I remove mOwner from the mix (and in the script file) everything works and runs fine.
}
酷!但爲了實現這個目標,luabind需要知道mOwner(實體*)是什麼並且已經定義了。所以,我在不同的文件中定義它:
// GameScriptingSystem.cpp
using namespace luabind;
module(inLuaState)
[
class_<GameObject>("GameObject"),
class_<Entity, bases<GameObject> >("Entity")
.def("DebugGetName", &Entity::DebugGetName)
];
流程看起來是這樣的:
結果:
錯誤C2504: '實體':基類未定義
按要求填寫完整錯誤:
...
2> Component.cpp
2> ScriptComponent.cpp
2>boost/type_traits/is_polymorphic.hpp(46): error C2504: 'Entity' : base class undefined
2> boost/type_traits/is_polymorphic.hpp(62) : see reference to class template instantiation 'boost::detail::is_polymorphic_imp1<T>::d2' being compiled
2> with
2> [
2> T=Entity
2> ]
2> boost/type_traits/is_polymorphic.hpp(97) : see reference to class template instantiation 'boost::detail::is_polymorphic_imp1<T>' being compiled
2> with
2> [
2> T=Entity
2> ]
2> boost/type_traits/is_polymorphic.hpp(102) : see reference to class template instantiation 'boost::detail::is_polymorphic_imp<T>' being compiled
2> with
2> [
2> T=Entity
2> ]
2> luabind/detail/make_instance.hpp(42) : see reference to class template instantiation 'boost::is_polymorphic<T>' being compiled
2> with
2> [
2> T=Entity
2> ]
2> luabind/detail/make_instance.hpp(74) : see reference to function template instantiation 'std::pair<_Ty1,_Ty2> luabind::detail::get_dynamic_class<T>(lua_State *,T *)' being compiled
2> with
2> [
2> _Ty1=luabind::detail::class_id,
2> _Ty2=void *,
2> T=Entity
2> ]
2> luabind/detail/policy.hpp(228) : see reference to function template instantiation 'void luabind::detail::make_instance<T*>(lua_State *,P)' being compiled
2> with
2> [
2> T=Entity,
2> P=Entity *
2> ]
2> luabind/detail/convert_to_lua.hpp(87) : see reference to function template instantiation 'void luabind::detail::pointer_converter::apply<Entity>(lua_State *,T *)' being compiled
2> with
2> [
2> T=Entity
2> ]
2> luabind/object.hpp(1072) : see reference to function template instantiation 'void luabind::detail::convert_to_lua_p<1,Entity*,Policies>(lua_State *,const T &,const Policies &)' being compiled
2> with
2> [
2> Policies=luabind::detail::null_type,
2> T=Entity *
2> ]
2> luabind/object.hpp(1140) : see reference to function template instantiation 'void luabind::detail::push_args_from_tuple<Index>::apply<T0,boost::tuples::detail::map_tuple_to_cons<boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type>::type,luabind::detail::null_type>(lua_State *,const boost::tuples::cons<HT,TT> &,const Policies &)' being compiled
2> with
2> [
2> Index=1,
2> T0=Entity *const *,
2> HT=Entity *const *,
2> TT=boost::tuples::detail::map_tuple_to_cons<boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type>::type,
2> Policies=luabind::detail::null_type
2> ]
2> luabind/object.hpp(1140) : see reference to function template instantiation 'void luabind::detail::push_args_from_tuple<Index>::apply<T0,boost::tuples::detail::map_tuple_to_cons<boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type>::type,luabind::detail::null_type>(lua_State *,const boost::tuples::cons<HT,TT> &,const Policies &)' being compiled
2> with
2> [
2> Index=1,
2> T0=Entity *const *,
2> HT=Entity *const *,
2> TT=boost::tuples::detail::map_tuple_to_cons<boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type>::type,
2> Policies=luabind::detail::null_type
2> ]
2> luabind/object.hpp(1112) : see reference to function template instantiation 'luabind::adl::object luabind::adl::call_proxy<ValueWrapper,Arguments>::call<luabind::detail::null_type>(Policies *)' being compiled
2> with
2> [
2> ValueWrapper=luabind::adl::index_proxy<luabind::adl::object>,
2> Arguments=boost::tuples::tuple<Entity *const *,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type>,
2> Policies=luabind::detail::null_type
2> ]
2> luabind/object.hpp(1112) : see reference to function template instantiation 'luabind::adl::object luabind::adl::call_proxy<ValueWrapper,Arguments>::call<luabind::detail::null_type>(Policies *)' being compiled
2> with
2> [
2> ValueWrapper=luabind::adl::index_proxy<luabind::adl::object>,
2> Arguments=boost::tuples::tuple<Entity *const *,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type>,
2> Policies=luabind::detail::null_type
2> ]
2> luabind/object.hpp(1110) : while compiling class template member function 'luabind::adl::call_proxy<ValueWrapper,Arguments>::~call_proxy(void)'
2> with
2> [
2> ValueWrapper=luabind::adl::index_proxy<luabind::adl::object>,
2> Arguments=boost::tuples::tuple<Entity *const *,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type>
2> ]
2> ..\src\Game\GameObjects\Components\ScriptComponent.cpp(75) : see reference to function template instantiation 'luabind::adl::call_proxy<ValueWrapper,Arguments>::~call_proxy(void)' being compiled
2> with
2> [
2> ValueWrapper=luabind::adl::index_proxy<luabind::adl::object>,
2> Arguments=boost::tuples::tuple<Entity *const *,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type>
2> ]
2> ..\src\Game\GameObjects\Components\ScriptComponent.cpp(75) : see reference to class template instantiation 'luabind::adl::call_proxy<ValueWrapper,Arguments>' being compiled
2> with
2> [
2> ValueWrapper=luabind::adl::index_proxy<luabind::adl::object>,
2> Arguments=boost::tuples::tuple<Entity *const *,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type>
2> ]
2>boost/type_traits/is_polymorphic.hpp(34): error C2504: 'Entity' : base class undefined
2> boost/type_traits/is_polymorphic.hpp(62) : see reference to class template instantiation 'boost::detail::is_polymorphic_imp1<T>::d1' being compiled
2> with
2> [
2> T=Entity
2> ]
2> Map.cpp
2> Generating Code...
2> Compiling...
2> GameScriptingSystem.cpp
2> PoCToolsInterface.cpp
..
據我所知,它由於構建順序。我最好的猜測是Luabind在編譯時完成了所有這些工作,並且當我首先查看編譯時,ScriptComponent首先編譯爲,GameScriptSystem編譯後是。當ScriptComponent構建時,全部通過luabind錯誤。 GameScriptSystem建立再經過(其中定義了所有的東西LuaBind抱怨)
所以:
如何跟蹤我的建造順序?查看哪些文件觸發了其他人的構建,以便我可以根據自己的喜好重新安排它? (它的一個大項目,它不像看着它2秒)
如果你知道luabind,我對這是問題嗎?
其他數據:
-- myScript.lua
local Cat = {}
local ticks = 0
function Cat.run(entity)
ticks = ticks + 1
LOG(tostring(ticks))
LOG(entity:DebugGetName())
end
return Cat
請提供完整的錯誤消息:錯誤消息+文件名+行號+該行的代碼段+/-多於3個代碼行 – dualed
好吧,我試着最小化它以保持其可讀性。我添加了更多我使用的文件,以及整個錯誤,以及我的結構圖和貓腳本 – MintyAnt