From 03b3be0f510c2ee6e6d68448b6f1f11086ebfc4a 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 8f814f0d37..93c409b030 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 26d7c0f0f4..b1d544dc5d 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 7682db599a..79d7477220 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 95abe71288..05d223bb36 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 54b18b9c2e..b10c82e88f 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 486b1b916a..6bf23f331c 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 915dfd7c02..13a610048e 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