Ask Your Question

Revision history [back]

Compilation errors with Clang

The following code works fine with VS2010 but does not compile with Clang (XCode for iOS):

  void test()
  {
     using namespace cv;
     cv::Point p;
     cv::Point2f q1 = p;
     cv::Point2f q2;
     q2 = p;
     cv::Point2f q3(p);                              // (1) Works on VS2010 but NOT with Clang
     cv::Point2f q4 = (cv::Point2f)p;                // (2) Works on VS2010 but NOT with Clang
     cv::Point2f q5 = p.operator cv::Point2f();

     cv::Mat a(10,10,CV_8UC1);
     Rect rec(0,0,2,2);
     cv::rectangle(a, rec, cv::Scalar::all(0));
     cv::rectangle(a(rec), rec, cv::Scalar::all(0)); // (3) Works on VS2010 but NOT with Clang
  }

There seems to be issues regarding the casting operator with the first two, and a problem converting a temporary to a non-const l-value with the last.

Here is the error I get for (1):

.../test.cpp:368:17: Call to constructor of 'cv::Point2f' (aka 'Point_<float>') is ambiguous

The error for (2):

.../test.cpp:369:22: Ambiguous conversion for C-style cast from 'cv::Point' (aka 'Point_<int>') to 'cv::Point2f' (aka 'Point_<float>')

and the error for (3):

.../test.cpp:375:5: No matching function for call to 'rectangle'
.../core.hpp:2594:17: Candidate function not viable: expects an l-value for 1st argument