Visual Studio Error C2244 in core/operations.hpp with option /analyze (Patch #1133)


Added by Linus Atorf almost 14 years ago. Updated almost 13 years ago.


Status:Done Start date:
Priority:Normal Due date:
Assignee:Andrey Kamaev % Done:

0%

Category:core
Target version:2.4.0
Affected version: Operating System:
Difficulty: HW Platform:
Pull request:

Description

Hi!

Basically my problem is already described here: http://stackoverflow.com/questions/4763786/opencv-error-c2244/

When you turn on the compiler option /analyze in Visual Studio 2008 or 2010 (go to Project properties, configuration, C/C++, Advanced, Code Analysis, yes (/analyze)), the project won't compile. You'll get these errors:

error C2244: 'cv::Matx<_Tp~>::diag' : unable to match function definition to an existing declaration
C:\Program Files\OpenCV2.2\include\opencv2\core\operations.hpp  (371)

error C2244: 'cv::Matx<_Tp~>::diag' : unable to match function definition to an existing declaration
C:\Program Files\OpenCV2.2\include\opencv2\core\operations.hpp  (447)

This is annoying, asyou cannot use Visual Studio's code analysis in projects that include OpenCV!

I could fix the first error. Line 365 in operations.hpp (OpenCV 2.2) was:

1template<typename _Tp, int m, int n> inline
2Matx<_Tp,m,n> Matx<_Tp,m,n>::diag(const Matx<_Tp,MIN(m,n),1>& d)

The fixed version is:

1template<typename _Tp, int m, int n> inline
2Matx<_Tp,m,n> Matx<_Tp,m,n>::diag(const diag_type& d)

However, I couldn't fix the second error in line 447. I think fixing this would really benefit Visual Studio users.

Best regards,
Linus Atorf


opencv-analyze-fix.patch (1.3 kB) uganson -, 2012-01-05 06:38 pm


Associated revisions

Revision 1af9b8ec
Added by Andrey Kamaev almost 13 years ago

Applied patch from #1133

Revision 73b10bc8
Added by Roman Donchenko over 11 years ago

Merge pull request #1133 from abidrahmank:denoising_pydocs

History

Updated by Linus Atorf over 13 years ago

I just noticed that not all versions of Visual Studio come with the Code Analysis feature. In VS 2008, you need a Team System version, for example.

Updated by Vadim Pisarevsky over 13 years ago

I remember that using diag_type broke build with some GCC versions. We can perhaps use conditional compilation. Anyway, priority of the bug should be lowered.

Updated by uganson - about 13 years ago

I attach a patch that fixes this issue. Tested on VS 2010 and compiling with the /analize option.

Using diag_type alone fails in GCC because it is not fully qualified (e.g. typename Matx<_Tp, m, n>::diag_type).

Updated by Alexander Shishkov about 13 years ago

  • Description changed from Hi! Basically my problem is already described here: http://stackoverflow.com... to Hi! Basically my problem is already described here: http://stackoverflow.com... More

Updated by Kirill Kornyakov about 13 years ago

  • Tracker changed from Feature to Patch

Updated by Alexander Shishkov almost 13 years ago

  • Target version deleted ()

Updated by Alexander Shishkov almost 13 years ago

  • Assignee deleted (Vadim Pisarevsky)

Updated by Andrey Kamaev almost 13 years ago

Thanks for the patch! It was applied in r7747.
It also solves the problem for MSVS 2008 and compiles well with gcc.

  • Status changed from Open to Done
  • Assignee set to Andrey Kamaev

Updated by Alexander Shishkov almost 13 years ago

  • Target version set to 2.4.0

Also available in: Atom PDF