当前位置:   article > 正文

c++ error: ‘this’ was not captured for this lambda function

c++ error: ‘this’ was not captured for this lambda function


    auto ResponseCB1 = [&rtk_event_register](void * context, xag_nav::os::Xap2Frame & fram, uint16_t errcode) {
        XAG_LOG_I("in CamRegisterToCpsRtkEvent errcode %d", errcode);
        XAG_LOGF_I("This is a respond, form {}, to {}.", fram.from(),
                  fram.to());
        XAG_LOGF_I("context : {}", (char*)context);
        XAG_LOGF_I("sequence : {}", fram.sequence());
        XAG_LOGF_I("timestamp : {}", fram.timestamp());
        XAG_LOGF_I("timeout : {}", fram.timeout());
        XAG_LOGF_I("responsedata: {}", fram.data());

        XAG_LOG_I("GPS-RTK Event init success!!!");

        rtk_event_register = RtkEventStatus::Success;
    };

修改为:


    auto ResponseCB1 = [this](void * context, xag_nav::os::Xap2Frame & fram, uint16_t errcode) {
        XAG_LOG_I("in CamRegisterToCpsRtkEvent errcode %d", errcode);
        XAG_LOGF_I("This is a respond, form {}, to {}.", fram.from(),
                  fram.to());
        XAG_LOGF_I("context : {}", (char*)context);
        XAG_LOGF_I("sequence : {}", fram.sequence());
        XAG_LOGF_I("timestamp : {}", fram.timestamp());
        XAG_LOGF_I("timeout : {}", fram.timeout());
        XAG_LOGF_I("responsedata: {}", fram.data());

        XAG_LOG_I("GPS-RTK Event init success!!!");

        rtk_event_register = RtkEventStatus::Success;
    };

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Guff_9hys/article/detail/1020889
推荐阅读
相关标签
  

闽ICP备14008679号