【问题标题】:LuaBind assert( id < local_id_base )LuaBind 断言(id < local_id_base)
【发布时间】:2013-06-04 23:04:36
【问题描述】:

我已经挣扎了很长时间了。 每当我尝试在 luabind 中定义一个类时,我都会遇到断言失败

assert( id < local_id_base ) in inheritance.hpp (luabind)

我尝试了很多不同的 luabind 叉子,但都没有成功。 尽管它们都是用 boost 1.53 和 Visual Studio 2012 编译的。 还有 lua 5.2.1

这是我正在使用的代码,仅用于

extern "C"
{
#include "lua.h"
#include "lauxlib.h"
#include "lualib.h"
}

#include <luabind/luabind.hpp>
#include <luabind/class.hpp>
#include <luabind/function.hpp>
#include <luabind/object.hpp>


    class TestStruct 
    {
    public:
        TestStruct(const std::string& s): m_string(s) {}
        void printmsg() { printf("Works"); };
    private:
        int i; 
        std::string m_string;
    };


int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
                       _In_opt_ HINSTANCE hPrevInstance,
                       _In_ LPTSTR    lpCmdLine,
                       _In_ int       nCmdShow)
{
    UNREFERENCED_PARAMETER(hPrevInstance);
    UNREFERENCED_PARAMETER(lpCmdLine);

    lua_State* L = luaL_newstate();

    luaopen_io (L);
    luaopen_base(L);
    luaopen_table(L);
    luaopen_string(L);
    luaopen_math(L);

    using namespace luabind;

    open(L);

    module(L)
        [
            class_<TestStruct>("TestStruct")
            .def(constructor<const std::string&>())
            .def("printmsg", &TestStruct::printmsg)


        ];


    lua_close(L);

    return 0;
}

[已解决]

在阅读之后,我几乎一无所获。 所以我所做的是在同一个项目中构建 LuaBind 和 Lua 5.2.2,创建一个库而不是两个单独的库。

【问题讨论】:

    标签: c++ c lua assert luabind


    【解决方案1】:

    你的类是本地的,因此对 LuaBind 的模板不可见。将班级移出main()

    如果这没有帮助,请检查您是否正确构建了 LuaBind - http://www.ogre3d.org/forums/viewtopic.php?f=2&t=75829

    【讨论】:

    • 没看到(将编辑我的帖子)虽然这不是问题。
    猜你喜欢
    • 2011-09-08
    • 1970-01-01
    • 1970-01-01
    • 2019-03-14
    • 2019-03-01
    • 2012-05-20
    • 2012-07-11
    • 1970-01-01
    • 2018-02-23
    相关资源
    最近更新 更多