Visual Studio Error C2244 in core/operations.hpp with option /analyze (Patch #1133)
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
Associated revisions
Applied patch from #1133
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