随笔分类 -  C++ 漫漫捉虫路

记录编程中出现的Bug以及解决方案
SSE优化指令集编译错误: inlining failed in call to always_inline 'xxx': target specific option mismatch xxx
摘要:在用QtCreator编译SSE优化指令的时候,出现了如下错误, inlining failed in call to always_inline '__m128i _mm_packus_epi32(__m128i, __m128i)': target specific option mismatc 阅读全文

posted @ 2017-10-23 09:23 defe_feath 阅读(3429) 评论(0) 推荐(0)

error: invalid use of incomplete type
摘要:一. 首先,要确定自己定义的类是完整的,构造函数,析构函数都有,函数的声明及定义分开在.h和.cpp中实现。 如果确定类是完整的,仍然出现error: invalid use of incomplete type的报错,那么问题出现在该类的使用上,而不是类的实现上. 二. 在使用某个已经实现的类时: 阅读全文

posted @ 2017-09-02 10:19 defe_feath 阅读(20106) 评论(0) 推荐(0)

老生常谈,正确使用memset
摘要:原文地址:http://blog.csdn.net/my_business/article/details/40537653 前段项目中发现一个问题,程序总是在某个dynamic_cast进行动态转换时出异常,查了半天才发现问题原来是出在memset的使用上,虽然问题本身显而易见,但当处于几十万行代 阅读全文

posted @ 2017-08-28 07:49 defe_feath 阅读(360) 评论(0) 推荐(0)

vector 大小
摘要:vector定义以后就最好确定大小resize(),否则在vector析构时可能出现 "double free or corruption"这样的错误 阅读全文

posted @ 2017-07-20 08:32 defe_feath 阅读(175) 评论(0) 推荐(0)

std::thread “terminate called without an active exception”
摘要:最近在使用std::thread的时候,遇到这样一个问题: 如果不使用调用t.join()就会遇到 "terminate called whithout an active exception",但是在使用boost:thread的时候却没遇到这个问题,google了一下,找到答案: The tro 阅读全文

posted @ 2017-06-28 13:27 defe_feath 阅读(461) 评论(0) 推荐(0)

error: templates may not be ‘virtual’
摘要:模板函数不能是虚函数,原因如下: 首先呢,模板函数并不是函数,他需要特定的类型去实例化成为函数。你定义一个函数模板,是不生成任何函数的,只有当你用代码去调用它时,才会根据你的类型去实例化成为特定的函数。而virtual函数是要写入虚函数表的,是必须要存在的。你可能会想到纯虚函数,纯虚函数只是表明这个 阅读全文

posted @ 2017-05-14 12:47 defe_feath 阅读(1115) 评论(0) 推荐(0)

OO易错点总结
摘要:在写子类的构造函数时,要在初始化列表中指定使用的父类的构造函数并完成其初始化,如下例: 阅读全文

posted @ 2017-05-13 22:34 defe_feath 阅读(163) 评论(0) 推荐(0)

error:对‘vtable for new_sequence’未定义的引用 对‘typeinfo for num_sequence’未定义的引用
摘要:在设计父类子类继承关系中,经常会出现此类问题。 报错原因:父类中的虚函数只有声明,没有定义。 解决方案 : 1. 定义相关的虚函数的实现。 2. 不实现了,直接搞成纯虚函数留给后代实现。 virtual int getlength()const = 0; 阅读全文

posted @ 2017-05-13 22:28 defe_feath 阅读(1221) 评论(0) 推荐(0)

error:: undefined reference to symbol '__glewBufferSubData' 未定义的引用 以及 error: main.o: undefined reference to symbol 'glTexImage2D'
摘要:在把DSO移植到QT工程中,出现了 报错,原因是.pro文件中没有加 GLEW库。 解决方案: 在.pro文件中加上这句: error: main.o: undefined reference to symbol 'glTexImage2D' 报错,原因是.pro文件中没有加OpenGL 解决方案: 阅读全文

posted @ 2017-05-12 18:01 defe_feath 阅读(731) 评论(0) 推荐(0)

error:未定义的引用
摘要:用qtcreator编程的话,先在.pro文件中这样写: 添加库及包含目录,然后再使用! 然后再在.h中写上#include,就可以正常使用了。 阅读全文

posted @ 2017-05-11 21:42 defe_feath 阅读(226) 评论(0) 推荐(0)

g2o使用bug总结
摘要:g2o进行3d2d优化的时候,设置优化图的边时,注意setVertex()中顶点的顺序。 buildSystem(): NaN within Jacobian for edge 0x8bd4f0 for vertex 0。 阅读全文

posted @ 2017-05-11 16:36 defe_feath 阅读(1305) 评论(0) 推荐(1)

error: declaration of 'cv::Mat R ' shadows a parameter
摘要:变量被覆盖。 例: 阅读全文

posted @ 2017-05-11 09:41 defe_feath 阅读(538) 评论(0) 推荐(0)