C++ 表达式,如 cerr、exit、string 在 eclipse c++ 中无法识别 IDE windows
C++ Expressions like cerr, exit, string not recognized in eclipse c++ IDE windows
我正在使用 eclipse C/C++ IDE 并且我有以下代码:
using namespace std;
using namespace g2o;
using namespace Eigen;
// sort according to max id, dimension
struct IncrementalEdgesCompare {
bool operator()(SparseOptimizer::Edge* const & e1, SparseOptimizer::Edge* const & e2)
{
const SparseOptimizer::Vertex* to1 = static_cast<const SparseOptimizer::Vertex*>(e1->vertices()[1]);
const SparseOptimizer::Vertex* to2 = static_cast<const SparseOptimizer::Vertex*>(e2->vertices()[1]);
int i11 = e1->vertices()[0]->id(), i12 = e1->vertices()[1]->id();
if (i11 > i12){
swap(i11, i12);
}
int i21 = e2->vertices()[0]->id(), i22 = e2->vertices()[1]->id();
if (i21 > i22){
swap(i21, i22);
}
if (i12 < i22)
return true;
if (i12 > i22)
return false;
// push the odometry to be the first
return to1->dimension() > to2->dimension();
}
};
void sigquit_handler(int sig)
{
if (sig == SIGINT) {
hasToStop = 1;
static int cnt = 0;
if (cnt++ == 2) {
cerr << __PRETTY_FUNCTION__ << " forcing exit" << endl;
exit(1);
}
}
}
我的问题是无法识别典型的 C++ 表达式,如 cerr、退出字符串。有什么问题?
您需要告诉索引器,在哪里可以找到标准包含文件。
转到您的项目设置并在 "Paths and Symbols" 部分中添加标准包含文件的路径,如 here 所述。
之后重建索引,或者在要求时选择是。
如果您使用 CMake 作为项目的构建系统而不是内部构建器,Eclipse CDT 无法检索该信息。
我正在使用 eclipse C/C++ IDE 并且我有以下代码:
using namespace std;
using namespace g2o;
using namespace Eigen;
// sort according to max id, dimension
struct IncrementalEdgesCompare {
bool operator()(SparseOptimizer::Edge* const & e1, SparseOptimizer::Edge* const & e2)
{
const SparseOptimizer::Vertex* to1 = static_cast<const SparseOptimizer::Vertex*>(e1->vertices()[1]);
const SparseOptimizer::Vertex* to2 = static_cast<const SparseOptimizer::Vertex*>(e2->vertices()[1]);
int i11 = e1->vertices()[0]->id(), i12 = e1->vertices()[1]->id();
if (i11 > i12){
swap(i11, i12);
}
int i21 = e2->vertices()[0]->id(), i22 = e2->vertices()[1]->id();
if (i21 > i22){
swap(i21, i22);
}
if (i12 < i22)
return true;
if (i12 > i22)
return false;
// push the odometry to be the first
return to1->dimension() > to2->dimension();
}
};
void sigquit_handler(int sig)
{
if (sig == SIGINT) {
hasToStop = 1;
static int cnt = 0;
if (cnt++ == 2) {
cerr << __PRETTY_FUNCTION__ << " forcing exit" << endl;
exit(1);
}
}
}
我的问题是无法识别典型的 C++ 表达式,如 cerr、退出字符串。有什么问题?
您需要告诉索引器,在哪里可以找到标准包含文件。
转到您的项目设置并在 "Paths and Symbols" 部分中添加标准包含文件的路径,如 here 所述。
之后重建索引,或者在要求时选择是。
如果您使用 CMake 作为项目的构建系统而不是内部构建器,Eclipse CDT 无法检索该信息。