Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/130.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ C++;11 luabind集成,功能失败_C++_Lua_Luabind - Fatal编程技术网

C++ C++;11 luabind集成,功能失败

C++ C++;11 luabind集成,功能失败,c++,lua,luabind,C++,Lua,Luabind,我正在尝试用luabind将LUA集成到我的程序中,但我遇到了一个大障碍 我对LUA的通话习惯非常陌生,我觉得我错过了一些简单的事情 这是我的C++代码: struct app_t { //... void exit(); void reset(); resource_mgr_t resources; //... }; struct resource_mgr_t { //... void prune(); void purge(

我正在尝试用
luabind
将LUA集成到我的程序中,但我遇到了一个大障碍

我对LUA的通话习惯非常陌生,我觉得我错过了一些简单的事情

这是我的C++代码:

struct app_t
{
    //...
    void exit();
    void reset();

    resource_mgr_t resources;
    //...
};

struct resource_mgr_t
{
    //...
    void prune();
    void purge();
    //...
};

extern app_t app;
和我的
luabind
模块:

luabind::module(state)
    [
        luabind::class_<resource_mgr_t>("resource_mgr")
        .def("prune", &resource_mgr_t::prune)
        .def("purge", &resource_mgr_t::purge)
    ];

luabind::module(state)
    [
        luabind::class_<app_t>("app")
        .def("exit", &app_t::exit)
        .def("reset", &app_t::reset)
        .def_readonly("resources", &app_t::resources)
    ];

luabind::globals(state)["app"] = &app;
但是,以下调用失败:

app.resources:purge()
出现以下错误:

[string "app.resources:purge()"]:1: attempt to index field 'resources' (a function value)
非常感谢您的帮助

而且,正如在
app:reset()
中一样,resources是一个实例成员字段

所以,像这样使用它:

app:resources():purge()

app:resources():purge()
现在产生运行时错误
luabind:property\u标记函数无法调用
。请尝试
app.resources():purge()
。(我现在不能测试。)我得到了同样的错误:(显然我可能需要重建luabind库。()我在使用它时遇到了奇怪的错误,例如仅仅包含
导致程序无法编译。我重建了所有库,现在看起来更稳定了一点(例如,我现在可以使用
中的东西)。然而,我仍然无法运行该命令,而不会出现同样的错误。:/我记得听到一些关于制作对象包装器所需的信息,这是否适用于这里?对于那些遇到这种情况的人,我最终选择了Python而不是Lua…它更易于使用,而且文档记录也更好。
app:resources():purge()