Eclipse CDT syntax error parser false error with Mat assignment: It compiles and runs ok

流过昼夜 提交于 2019-12-13 00:04:09

问题


In this line of code, the x is red underlined as error:

cv::Mat x = cv::Mat::eye(2,2,CV_8U);

with this description:

Invalid arguments '
Candidates are:
 Mat()
 Mat(int, int, int)
 Mat(int, int, int, const cv::Scalar_<double> &)
 ... (it goes on, full error description at the bottom)

It compiles and runs ok.

09:12:02 Build Finished. 0 errors, 0 warnings. (took 1s.721ms)

It used to work fine. I can't tell exactly when this started, but in the middle I updated Eclipse to the last stable version Version: 2019-06 (4.12.0) Build id: 20190614-1200.

It's something with the parser. I'm using elf-parser as error parser (the default configuration for Linux). I tried with c++11 and c++17, and without telling which C++ to use.

The generic false error happens when assigning a MatExpr to a Mat declaration. MatExpr is supposed to be automatically cast to Mat (like it always did). It's too specific to opencv, but sometimes error parser fails to recognize std::endl, so I believe the problem with the parser isn't specific to opencv.

Full error description for completeness, I'm pretty sure there is nothing relevant here:

Invalid arguments '
Candidates are:
 Mat()
 Mat(int, int, int)
 Mat(int, int, int, const cv::Scalar_<double> &)
 Mat(cv::Size_<int>, int)
 Mat(cv::Size_<int>, int, const cv::Scalar_<double> &)
 Mat(int, const int *, int)
 Mat(int, const int *, int, const cv::Scalar_<double> &)
 Mat(const std::vector<int,std::allocator<int>> &, int)
 Mat(const std::vector<int,std::allocator<int>> &, int, const cv::Scalar_<double> &)
 Mat(const cv::Mat &)
 Mat(int, int, int, void *, unsigned long int)
 Mat(cv::Size_<int>, int, void *, unsigned long int)
 Mat(const std::vector<#0,std::allocator<#0>> &, bool)
 Mat(std::initializer_list<#0>)
 Mat(std::initializer_list<int>, std::initializer_list<#0>)
 Mat(const std::array<#0,unsigned long int3 #1 0> &, bool)
 Mat(const cv::Vec<#0,int3 #1 0> &, bool)
 Mat(const cv::Matx<#0,int3 #1 0,int3 #2 0> &, bool)
 Mat(const cv::Point_<#0> &, bool)
 Mat(const cv::Point3_<#0> &, bool)
 Mat(const cv::MatCommaInitializer_<#0> &)
 Mat(const cv::Mat &, const cv::Range &, const cv::Range &)
 Mat(const cv::Mat &, const cv::Rect_<int> &)
 Mat(const cv::Mat &, const cv::Range *)
 Mat(const cv::Mat &, const std::vector<cv::Range,std::allocator<cv::Range>> &)
 Mat(cv::Mat &&)
 Mat(int, const int *, int, void *, const unsigned long int *)
 Mat(const std::vector<int,std::allocator<int>> &, int, void *, const unsigned long int *)
 Mat(const cv::cuda::GpuMat &)
'

回答1:


This is a bug in Eclipse's C++ parser, filed as bug 550397.

UPDATE: I also have a fix for it.



来源:https://stackoverflow.com/questions/57626348/eclipse-cdt-syntax-error-parser-false-error-with-mat-assignment-it-compiles-and

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!