当前位置:网站首页>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”如何调试
边栏推荐
猜你喜欢

MATLAB绘图函数ezplot入门详解

Codeforces Round #605 (Div. 3)

Introduction to MATLAB drawing functions ezplot explanation

How to simulate 1/3 probability with coins, and arbitrary probability?

EastWave应用:光场与石墨烯和特异介质相互作用的研究

TCP的三次握手和四次挥手

Based on the least squares linear regression equation coefficient estimation

第三十章:普通树的存储和遍历

剑指offer:合并两个排序的链表

深入理解Mysql索引底层数据结构与算法
随机推荐
Detailed introduction to the hierarchical method of binary tree creation
Unity-编辑器扩展(Editor)
Unity Line-Renderer
TypeScript
Based on the least squares linear regression equation coefficient estimation
Knapsack Problem - Dynamic Programming - Theory
mysql学习总结 & 索引
Redis 学习part one
第二十九章:树的基本概念和性质
关于混淆的问题
shader入门精要1
专硕与学硕
光学好书推荐
unity 和C# 一些官方优化资料
第三十一章:二叉树的概念与性质
2021-03-12
冷读123
Qt | 定时器的使用 QTimer
1.开发社区首页,注册
Happy, 9/28 scene collection