当前位置:网站首页>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”如何调试
边栏推荐
猜你喜欢
Open the door of power and electricity "Circuit" (2): Power Calculation and Judgment
MATLAB绘图函数fplot详解
pygame draw arc
泰伯效应的建模
Introduction to MATLAB drawing functions ezplot explanation
剑指offer:删除链表中重复的节点
How to simulate 1/3 probability with coins, and arbitrary probability?
第三十一章:二叉树的概念与性质
第二十五章:一文掌握while循环
MMD->Unity一站式解决方案
随机推荐
Installation and configuration of Spark and related ecological components - quick recall
MATLAB绘图函数fplot详解
Codeforces Round #605 (Div. 3)
十天学习Unity3D脚本(一)九个回调
Unity-PlayMaker
KiCad Common Shortcuts
Introduction to in-order traversal (non-recursive, recursive) after binary tree traversal
饥荒联机版Mod开发——准备工具(一)
LeetCode 2353. 设计食物评分系统 维护哈希表+set
Qt | 定时器的使用 QTimer
7.Redis
求解斐波那契数列的若干方法
Unity-3D数学
unity Domain Reload & scene Reload 静态变量重置
Detailed introduction to drawing complex surfaces using the plot_surface command
深入理解Mysql索引底层数据结构与算法
第二十六章:二维数组
Redis common interview questions
Flink + sklearn - use JPMML implement flink deployment on machine learning model
Knapsack Problem - Dynamic Programming - Theory