stack_overflow
递归次数过多爆栈辣
heap-buffer-overflow
内存是否存在非法访问
默认构造函数
call to implicitly-deleted default constructor of ‘unordered_set<vector >’
unordered_set基于hashtable实现,而我所使用的key_value是vector<int>
没有hash键值
struct hashfunc
{
template<typename T, typename U>
size_t operator() (const pair<T, U> &i) const
{
return hash<T>()(i.first) ^ hash<U>()(i.second);
}
};
unordered_map< pair<int, int>, int , hashfunc > mp;
struct MyKeyHashHasher
{
size_t operator()(const MyKey &k) const noexcept
{
return std::hash<int>{}(k.key);
}
};
duplicate symbols for architecture arm64
一个文件里的函数太多了,打算拆一部分到另一个.cpp,结果就报错。错因是函数或者全局变量重定义了,但是我注释掉所有的函数之后,只剩下头上的这些,大家来看看哪里出问题了hhhh
#include "mesh.h"
#include <iostream>
#include <fstream>
#include <QFileInfo>
#include <QString>
#define TINYOBJLOADER_IMPLEMENTATION
#include "util/tiny_obj_loader.h"
using namespace Eigen;
using namespace std;
好的揭晓答案,是#define TINYOBJLOADER_IMPLEMENTATION 。
This directive causes the implementation of TinyObjLoader to be included wherever this line is processed. If mesh.cpp or another file including mesh.h (or directly including util/tiny_obj_loader.h) also has or indirectly includes this directive, it will lead to multiple definitions of TinyObjLoader’s implementation, hence the duplicate symbols error. – from ChatGPT
只把这两行包含在用到obj loader的源文件里就解决啦。
map
// Create new faces.
Face* face_cma = new Face(F.size());
cout << "F " << F.size() << endl;
F.insert({F.size(), face_cma});
Face* face_cmd = new Face(F.size());
cout << "F " << F.size() << endl;
F.insert({F.size(), face_cmd});
Face* face_amb = new Face(F.size());
cout << "F " << F.size() << endl;
F.insert({F.size(), face_amb});
Face* face_dmb = new Face(F.size());
cout << "F " << F.size() << endl;
F.insert({F.size(), face_dmb});
发现原来F.size()不能作为key插入,因为