当前位置:网站首页>Debug on pure method is called
Debug on pure method is called
2022-08-02 14:12:00 【Soonyang Zhang】
#include <iostream>
#include <execinfo.h> //for backtrace
void dump(void)
{
int j, nptrs;
void *buffer[kBacktraceSize];
char **strings;
nptrs = backtrace(buffer, kBacktraceSize);
printf("backtrace() returned %d addresses\n", nptrs);
strings = backtrace_symbols(buffer, nptrs);
if (strings == NULL) {
perror("backtrace_symbols");
exit(EXIT_FAILURE);
}
for (j = 0; j < nptrs; j++)
printf("[%02d] %s\n", j, strings[j]);
free(strings);
}
extern "C"
void __cxa_pure_virtual () {
std::cout<<"pure method is called"<<std::endl;
dump();
}
Copy the above code in your own project. When the pure method is called, the dump will output some backtrace. The output hint may be helpful to let you figure out what is wrong.
Reference
[1] C++ 错误 pure virtual method called
[2] “Pure virtual function call”如何调试
边栏推荐
猜你喜欢
随机推荐
word方框怎么打勾?
第三十一章:二叉树的概念与性质
富文本编辑
7. Redis
饥荒联机版Mod开发——准备工具(一)
背包问题-动态规划-理论篇
第二十八章:解题技巧
Unity-Post Processing
Redis common interview questions
光学好书推荐
冷读123
Masters and Masters
3.用户上传头像
LeetCode 2353. 设计食物评分系统 维护哈希表+set
Unity-Ads广告插件
Use libcurl to upload the image of Opencv Mat to the file server, based on two methods of post request and ftp protocol
4.发布帖子,评论帖子
软件测试基础知识(背)
第三十二章:二叉树的存储与遍历
计算机导论——数据库