![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
C/C++ debug
文章平均质量分 64
十一月zz
leannnnnnnnnnnnnnning
展开
-
ImportError: /lib64/libatk-1.0.so.0: undefined symbol: g_type_check_instance_is_fundamentally_a
error log: import cv2ImportError: /lib64/libatk-1.0.so.0: undefined symbol: g_type_check_instance_is_fundamentally_a一步步来分析:为什么会报这个错误? => 这涉及到执行到import cv2, python是如何来找到cv2所在的路径的?答案是通过PYTHONPATH环境变量。其实我们pip intall库的时候,只是工具在背后帮我们把库放到了PYTHONPATH原创 2022-04-17 10:50:02 · 7139 阅读 · 0 评论 -
-Wshift-negative-value
/////* main.c *///////#include<stdio.h>int main(void) { int count = 2; printf("%d\n", ~0<<count); //warning printf("%d\n", ~0<<2); // warning:shifting a negative signed value is undefined [-Wshift-negative-value] return原创 2022-03-31 21:14:03 · 677 阅读 · 0 评论 -
getline和cin混用的问题
cin/getline是什么?cin其实是一个istream对象(object),参考这里。getline是一个标准库函数(function),参考这里。cin/getline停止读取的标志用cin来读取键盘输入的时候,遇到 "空格、tab、回车" 停止读取。 用getline来读取键盘输入的时候,遇到 "回车" 停止读取。cin/getline读取输入流的细节当cin读取键盘输入的时候,会先判断当前读取的字符是否是 "空格,tab,回车"的一种或者几种,如果是的话,则会自动跳过,从原创 2021-08-28 13:42:35 · 1062 阅读 · 0 评论 -
how to enable core dump in csh
转载:https://kb.iu.edu/d/awdhIf you're usingbashorksh, use theulimitcommand to check the stack size:[dartmaul@h2 ~]$ ulimit -acore file size (blocks, -c) 0data seg size (kbytes, -d) unlimitedscheduling priority (-e...转载 2021-08-06 16:31:26 · 422 阅读 · 0 评论 -
Python Exception exceptions.NameError Installation error: gdb.execute_unwinders function is missing:
提示标题所示错误的gdb 版本:gdb-7.10.1使用的gdb的时候遇到如标题所示的错误提示信息,其实不影响正常的使用,但是一直输出这个也很烦人,网上看了下,发现有可能是当前gdb版本的bug,或者当前gdb版本安装的问题。于是换了一个gdb-9.2 版本的gdb来使用,问题消失。参考:这里...原创 2021-02-23 21:28:32 · 3473 阅读 · 0 评论 -
C++ 前向声明(forward declaration)能做什么?
类的前向声明最主要的作用是在binary release的时候可以减少头文件的依赖。因为通常做binary release的时候,会release一个 release.h + release.so,release.h用来被用户include,那么 release.h中include的所有header file在用户的工作环境中也必须能找的到才可以。所以,release.h include的header file越少对用户也就越友好。考虑如下的两种release.h/*方法1*/#include "f原创 2021-01-11 20:34:45 · 765 阅读 · 1 评论 -
使用valgrind工具检测内存泄漏
因为公司服务器上面本身就安装有valgrind,所以我是直接拿过来使用的,并没有自己安装过,需要安装的朋友自己google安装吧。可以使用 which valgrind 命令来看自己电脑上是否已经安装上valgrind。useful link:valgrind 使用方法,参考这里valgrind 输出log解读,参考这里...原创 2021-01-11 19:57:52 · 214 阅读 · 0 评论 -
C++ class在执行到构造函数内部的时候 segment fault
1. 现象class A { uint_64 *p_a; uint_64 *p_b; uint_64 *p_c; ... ...}自定义的class A内部有三个指针成员变量,在instance class A生成对象的时候(执行到class A构造函数的内部的时候)发现这三个指针是分配到了内存的,即能看到指针的值。但是在后期使用这三个指针的时候,出现了segment fault。gdb进去发现其中一个指针的值变为了0,即指向了非法的地址,另外两个指针的值也变了。但是该对象的地址(即th原创 2021-01-12 19:11:25 · 718 阅读 · 0 评论 -
链接boost::program_options到自己的程序,解决/usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.21‘ not found 的问题
首先,我是在公司的服务器上面工作的,我没有root权限,公司的服务器上已经存在编译好了的boost程序,我需要做的仅仅是在写程序的时候把boost添加进来首先,main.cpp如下,我只是简单的想编译一个这个程序,然后运行起来。// Copyright Vladimir Prus 2002-2004.// Distributed under the Boost Software License, Version 1.0.// (See accompanying file LICENSE_1_0..原创 2020-10-30 11:36:36 · 542 阅读 · 0 评论 -
C++函数的隐藏(遮蔽)、覆盖(override,即重写,多态的实现原理)、重载(overload)
一、关于遮蔽,我们需要注意什么?我们知道C++的虚函数是为了实现多态。对于虚函数,有以下的几点需要注意: 1、基类和派生类成员的名字一样时会造成遮蔽 2、不管函数的参数如何,只要名字一样就会造成遮蔽。换句话说,基类成员函数和派生类成员函数不会构成重载,如果派生类有同名函数,那么就会遮蔽基类中的所有同名函数,不管它们的参数是否一样。 3、即使派生类的成员(包括成员变量和成员函数)和基类中成...原创 2018-07-01 10:35:09 · 1534 阅读 · 0 评论 -
a simple example:自定义程序的异常(exception)行为
#include <iostream>#include <exception>using namespace std;class DivideError: public exception{public: DivideError() :exception() {} const char* what(){ return "divide 0 error!!\n" ; }};double quotion(转载 2020-09-19 19:00:37 · 114 阅读 · 0 评论 -
深入理解C++对象的构造过程(笔记)
如果我们要通过某个class_A来instance一个对象object_A,通常要include class_A所在的头文件(class_A.h)。我的问题是,include class_A.h的作用是什么?答:很自然的,也是很表面的一个问题是,如果你不include class_A.h,编译会报错,会显示class_A是一个undefined type.深层次的理解是:include class_A是给编译器提供该class的原型,编译器根据这个原型来为object_A来分配空间。也就是分配.原创 2020-08-24 15:42:15 · 758 阅读 · 0 评论 -
error: invalid operands of types 'int()' and 'int' to binary 'operator%'
template template void BinNode::travPost(VST & visit){ switch(rand % 2){ //报错; case 1: travPost_I1( this, visit); break; default: travPost_R( this, visit); break; }}错误信息如原创 2018-01-04 18:50:14 · 54657 阅读 · 2 评论 -
error: 'NULL' was not declared in this scope
转自:http://blog.csdn.net/libing_zeng/article/details/55668666编译时出现这个错误:error: 'NULL' was not declared in this scope解决方式:在文件开头添加如下代码:#include 或者#include 或者#include转载 2018-01-04 17:05:04 · 10297 阅读 · 0 评论 -
error: lvalue required as left operand of assignment
#include int main(){ float a[5]; float e; int lo, hi, mi; int i; lo = 0; hi = 5; printf("please input e:"); scanf("%f", &e); printf("please input array:"); for(i原创 2018-01-03 20:37:57 · 35072 阅读 · 0 评论 -
error:passing 'const Student' as 'this' argument of 'void Student::print()' discards qualifiers
#include using namespace std;class Student{private: string _name;public: Student( const char * name) { _name = name; } void print(){ cout_name<<endl; }};int main()原创 2017-12-26 16:33:29 · 5007 阅读 · 0 评论 -
C++ 的 printf格式控制输出
测试平台:gcc (Ubuntu 4.8.5-4ubuntu8~16.04.1) 4.8.5%f,默认输出六位小数(对float和double类型都是默认输出六位小数),有效数字只是前6位(包括整数部分和小数部分)%lf,默认输出六位小数(对float和double类型都是默认输出六位小数),但是通过%.16lf使其输出为16位小数,但是有效数组只是前16位(包括整数部分和小数部分)...原创 2018-07-06 11:00:11 · 4146 阅读 · 0 评论 -
error: there are no arguments to ‘ignore’ that depend on a template parameter
测试;原创 2018-01-05 22:16:43 · 3478 阅读 · 0 评论