【问题标题】:QT show "RTTI symbol not found for class" but work fineQT 显示“找不到类的 RTTI 符号”但工作正常
【发布时间】:2016-02-26 16:16:21
【问题描述】:

我按照以下代码测试 shared_ptr 和 lambda 删除器。 它工作正常。但是在调试时,显示:

RTTI symbol not found for class 'std::_Sp_counted_deleter<cls*, main::{lambda(cls*)#1}, std::allocator<void>, (__gnu_cxx::_Lock_policy)2>'

我的代码有什么问题吗?

代码:

#include <iostream>
#include <memory>
using namespace std;

class cls{
public:
    void test(){
        cout << "ok\n";
    }

    virtual ~cls(){
       cout << "~cls()\n";
    }
};

typedef shared_ptr<cls> stptr;

int main(){
    auto del = [](cls* p){delete(p);};
    stptr p = stptr(new cls, del);
    p->test();
    return 0;
}

屏幕截图:

【问题讨论】:

    标签: qt c++11 lambda smart-pointers


    【解决方案1】:

    代码看起来不错。

    我在使用 GDB(使用 GCC 编译时 QtCreator 中的默认调试器)时遇到了同样的问题。我认为这是 GDB 在查找涉及 lambda 类型的 RTTI 时的问题。 使用 Clang 和 LLDB(如果您的系统上安装了 Clang,则在“工具包”中可用)我看不到这个问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-11-28
      • 2012-06-09
      • 1970-01-01
      • 2013-08-14
      • 2014-09-20
      • 2018-09-16
      • 2012-08-05
      • 1970-01-01
      相关资源
      最近更新 更多