当前位置:网站首页>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绘图函数plot详解
TCP的三次握手和四次挥手
【离散化+前缀和】Acwing802. 区间和
Detailed introduction to the hierarchical method of binary tree creation
队列与栈
二叉树创建之层次法入门详解
深入理解Mysql索引底层数据结构与算法
Introduction to MATLAB drawing functions ezplot explanation
Detailed explanation of MATLAB drawing function plot
Flink + sklearn - use JPMML implement flink deployment on machine learning model
随机推荐
剑指offer:数值的整数次方
LeetCode 2343. 裁剪数字后查询第 K 小的数字 暴力+语法考察
Software Testing Basics (Back)
计算机导论——数据库
MATLAB绘图函数plot详解
第三十二章:二叉树的存储与遍历
Detailed introduction to drawing complex surfaces using the plot_surface command
2342. 数位和相等数对的最大和 哈希优化
couldn't find 'libflutter.so' --flutter
第二十八章:解题技巧
UnityAPI-Ray-Physics
Qt | 实现一个简单的可以转动的仪表盘
TypeScript
背包问题-动态规划-理论篇
Redis 学习part one
Based on the matrix calculation in the linear regression equation of the coefficient estimates
远程连接Ubuntu中的Mysql
Unity-Post Processing
光波导的入射耦合和出射耦合区域
Detailed explanation of MATLAB drawing function plot