From a12e144e86355ec353b53c89e9cd39dd0e8cded4 Mon Sep 17 00:00:00 2001 From: Hamdi Sahloul Date: Wed, 12 Sep 2018 13:23:36 +0900 Subject: [PATCH] MSVC: Slience external/meaningless warnings --- modules/calib3d/src/dls.cpp | 9 +++++++++ modules/core/include/opencv2/core/private.hpp | 9 +++++++++ modules/core/src/cuda_stream.cpp | 4 ++++ modules/core/src/lapack.cpp | 15 ++++++++++++--- modules/core/src/opengl.cpp | 4 ++++ modules/features2d/src/matchers.cpp | 11 ++++++++++- modules/python/src2/cv2.cpp | 5 +++-- 7 files changed, 51 insertions(+), 6 deletions(-) diff --git a/modules/calib3d/src/dls.cpp b/modules/calib3d/src/dls.cpp index 8f814f0d3781..93c409b03035 100644 --- a/modules/calib3d/src/dls.cpp +++ b/modules/calib3d/src/dls.cpp @@ -7,8 +7,17 @@ # if defined __GNUC__ && defined __APPLE__ # pragma GCC diagnostic ignored "-Wshadow" # endif +# if defined(_MSC_VER) +# pragma warning(push) +# pragma warning(disable:4701) // potentially uninitialized local variable +# pragma warning(disable:4702) // unreachable code +# pragma warning(disable:4714) // const marked as __forceinline not inlined +# endif # include # include +# if defined(_MSC_VER) +# pragma warning(pop) +# endif # include "opencv2/core/eigen.hpp" #endif diff --git a/modules/core/include/opencv2/core/private.hpp b/modules/core/include/opencv2/core/private.hpp index 6f6457be1b84..b037fbd28211 100644 --- a/modules/core/include/opencv2/core/private.hpp +++ b/modules/core/include/opencv2/core/private.hpp @@ -57,7 +57,16 @@ # if defined __GNUC__ && defined __APPLE__ # pragma GCC diagnostic ignored "-Wshadow" # endif +# if defined(_MSC_VER) +# pragma warning(push) +# pragma warning(disable:4701) // potentially uninitialized local variable +# pragma warning(disable:4702) // unreachable code +# pragma warning(disable:4714) // const marked as __forceinline not inlined +# endif # include +# if defined(_MSC_VER) +# pragma warning(pop) +# endif # include "opencv2/core/eigen.hpp" #endif diff --git a/modules/core/src/cuda_stream.cpp b/modules/core/src/cuda_stream.cpp index 99cd1748db49..6790b0aa0ff2 100644 --- a/modules/core/src/cuda_stream.cpp +++ b/modules/core/src/cuda_stream.cpp @@ -45,6 +45,10 @@ using namespace cv; using namespace cv::cuda; +#if defined(_MSC_VER) +#pragma warning(disable : 4702) // unreachable code +#endif + ///////////////////////////////////////////////////////////// /// MemoryStack diff --git a/modules/core/src/lapack.cpp b/modules/core/src/lapack.cpp index dab427e20d68..ed10e73d73b0 100644 --- a/modules/core/src/lapack.cpp +++ b/modules/core/src/lapack.cpp @@ -44,9 +44,18 @@ #include #ifdef HAVE_EIGEN -#include -#include -#include "opencv2/core/eigen.hpp" +# if defined(_MSC_VER) +# pragma warning(push) +# pragma warning(disable:4701) // potentially uninitialized local variable +# pragma warning(disable:4702) // unreachable code +# pragma warning(disable:4714) // const marked as __forceinline not inlined +# endif +# include +# include +# if defined(_MSC_VER) +# pragma warning(pop) +# endif +# include "opencv2/core/eigen.hpp" #endif #if defined _M_IX86 && defined _MSC_VER && _MSC_VER < 1700 diff --git a/modules/core/src/opengl.cpp b/modules/core/src/opengl.cpp index e044c25cc450..ba57f1626837 100644 --- a/modules/core/src/opengl.cpp +++ b/modules/core/src/opengl.cpp @@ -54,6 +54,10 @@ using namespace cv; using namespace cv::cuda; +#if defined(_MSC_VER) +#pragma warning(disable : 4702) // unreachable code +#endif + namespace { #ifndef HAVE_OPENGL diff --git a/modules/features2d/src/matchers.cpp b/modules/features2d/src/matchers.cpp index 486b1b916aac..6bf23f331c67 100644 --- a/modules/features2d/src/matchers.cpp +++ b/modules/features2d/src/matchers.cpp @@ -44,7 +44,16 @@ #include "opencl_kernels_features2d.hpp" #if defined(HAVE_EIGEN) && EIGEN_WORLD_VERSION == 2 -#include +# if defined(_MSC_VER) +# pragma warning(push) +# pragma warning(disable:4701) // potentially uninitialized local variable +# pragma warning(disable:4702) // unreachable code +# pragma warning(disable:4714) // const marked as __forceinline not inlined +# endif +# include +# if defined(_MSC_VER) +# pragma warning(pop) +# endif #endif namespace cv diff --git a/modules/python/src2/cv2.cpp b/modules/python/src2/cv2.cpp index 03d34196a958..a0032b7e1a31 100644 --- a/modules/python/src2/cv2.cpp +++ b/modules/python/src2/cv2.cpp @@ -1,4 +1,5 @@ -#if defined(_MSC_VER) && (_MSC_VER >= 1800) +//warning number '5033' not a valid compiler warning in vc12 +#if defined(_MSC_VER) && (_MSC_VER > 1800) // eliminating duplicated round() declaration #define HAVE_ROUND 1 #pragma warning(push) @@ -6,7 +7,7 @@ #endif #include #include -#if defined(_MSC_VER) && (_MSC_VER >= 1800) +#if defined(_MSC_VER) && (_MSC_VER > 1800) #pragma warning(pop) #endif