From fe7b3f12289d5018a9db677822335437d0412407 Mon Sep 17 00:00:00 2001 From: Tomoaki Teshima Date: Fri, 22 Dec 2017 08:42:21 +0900 Subject: [PATCH] clean up the code * disable the warning in CMake, not int the code using pragma --- cmake/OpenCVCompilerOptions.cmake | 4 +--- modules/cudalegacy/test/NCVTest.hpp | 2 +- modules/features2d/src/agast.cpp | 4 ---- modules/features2d/src/agast_score.cpp | 4 ---- modules/features2d/src/fast.cpp | 3 --- modules/imgcodecs/src/grfmt_jpeg.cpp | 7 ------- modules/imgproc/src/canny.cpp | 4 ---- modules/ts/include/opencv2/ts.hpp | 1 - modules/ts/include/opencv2/ts/ts_gtest.h | 9 --------- modules/videoio/src/cap_ffmpeg_impl.hpp | 4 ++-- modules/videoio/src/cap_msmf.hpp | 9 --------- 11 files changed, 4 insertions(+), 47 deletions(-) diff --git a/cmake/OpenCVCompilerOptions.cmake b/cmake/OpenCVCompilerOptions.cmake index 47dc7051ad..353ee12ac1 100644 --- a/cmake/OpenCVCompilerOptions.cmake +++ b/cmake/OpenCVCompilerOptions.cmake @@ -309,9 +309,6 @@ if(MSVC) if(MSVC_VERSION EQUAL 1400) ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4510 /wd4610 /wd4312 /wd4201 /wd4244 /wd4328 /wd4267) endif() - if(MSVC_VERSION LESS 1900) # MSVS2015 - ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4127) # warning C4127: conditional expression is constant - endif() endif() # allow extern "C" functions throw exceptions @@ -323,6 +320,7 @@ if(MSVC) endforeach() if(NOT ENABLE_NOISY_WARNINGS) + ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4127) # conditional expression is constant ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4251) # class 'std::XXX' needs to have dll-interface to be used by clients of YYY ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4324) # 'struct_name' : structure was padded due to __declspec(align()) ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4275) # non dll-interface class 'std::exception' used as base for dll-interface class 'cv::Exception' diff --git a/modules/cudalegacy/test/NCVTest.hpp b/modules/cudalegacy/test/NCVTest.hpp index 23b1feef55..3d7bf47ff1 100644 --- a/modules/cudalegacy/test/NCVTest.hpp +++ b/modules/cudalegacy/test/NCVTest.hpp @@ -44,7 +44,7 @@ #define _ncvtest_hpp_ #if defined _MSC_VER -# pragma warning( disable : 4201 4408 4127 4100) +# pragma warning( disable : 4201 4408 4100) #endif #include diff --git a/modules/features2d/src/agast.cpp b/modules/features2d/src/agast.cpp index d1f1bb6927..ee14d06121 100644 --- a/modules/features2d/src/agast.cpp +++ b/modules/features2d/src/agast.cpp @@ -45,10 +45,6 @@ The references are: #include "precomp.hpp" #include "agast_score.hpp" -#ifdef _MSC_VER -#pragma warning( disable : 4127 ) -#endif - namespace cv { diff --git a/modules/features2d/src/agast_score.cpp b/modules/features2d/src/agast_score.cpp index ac80077aea..92a34a758e 100644 --- a/modules/features2d/src/agast_score.cpp +++ b/modules/features2d/src/agast_score.cpp @@ -44,10 +44,6 @@ The references are: #include "agast_score.hpp" -#ifdef _MSC_VER -#pragma warning( disable : 4127 ) -#endif - namespace cv { diff --git a/modules/features2d/src/fast.cpp b/modules/features2d/src/fast.cpp index c87ea69e13..f81e7e2c2c 100644 --- a/modules/features2d/src/fast.cpp +++ b/modules/features2d/src/fast.cpp @@ -48,9 +48,6 @@ The references are: #include "opencv2/core/hal/intrin.hpp" #include "opencv2/core/openvx/ovx_defs.hpp" -#if defined _MSC_VER -# pragma warning( disable : 4127) -#endif namespace cv { diff --git a/modules/imgcodecs/src/grfmt_jpeg.cpp b/modules/imgcodecs/src/grfmt_jpeg.cpp index caf768d256..f53550a0f7 100644 --- a/modules/imgcodecs/src/grfmt_jpeg.cpp +++ b/modules/imgcodecs/src/grfmt_jpeg.cpp @@ -78,18 +78,11 @@ extern "C" { namespace cv { -#ifdef _MSC_VER -# pragma warning(push) -# pragma warning(disable:4324) //structure was padded due to __declspec(align()) -#endif struct JpegErrorMgr { struct jpeg_error_mgr pub; jmp_buf setjmp_buffer; }; -#ifdef _MSC_VER -# pragma warning(pop) -#endif struct JpegSource { diff --git a/modules/imgproc/src/canny.cpp b/modules/imgproc/src/canny.cpp index 23bb40eebc..7c13e4d32c 100644 --- a/modules/imgproc/src/canny.cpp +++ b/modules/imgproc/src/canny.cpp @@ -47,10 +47,6 @@ #include "opencv2/core/openvx/ovx_defs.hpp" -#ifdef _MSC_VER -#pragma warning( disable: 4127 ) // conditional expression is constant -#endif - #if CV_SIMD128 #define CV_MALLOC_SIMD128 16 #endif diff --git a/modules/ts/include/opencv2/ts.hpp b/modules/ts/include/opencv2/ts.hpp index dd1bc14425..82e945aaa0 100644 --- a/modules/ts/include/opencv2/ts.hpp +++ b/modules/ts/include/opencv2/ts.hpp @@ -34,7 +34,6 @@ #endif #ifdef _MSC_VER -#pragma warning( disable: 4127 ) // conditional expression is constant #pragma warning( disable: 4503 ) // decorated name length exceeded, name was truncated #endif diff --git a/modules/ts/include/opencv2/ts/ts_gtest.h b/modules/ts/include/opencv2/ts/ts_gtest.h index fb31603bb0..18e64155df 100644 --- a/modules/ts/include/opencv2/ts/ts_gtest.h +++ b/modules/ts/include/opencv2/ts/ts_gtest.h @@ -7976,20 +7976,11 @@ GTEST_API_ std::string AppendUserMessage( // std::runtime_error inherits from std::exception, many testing // frameworks know how to extract and print the message inside it. -#ifdef _MSC_VER -# pragma warning(push) // Saves the current warning state. -# pragma warning(disable:4275) // Temporarily disables warning 4275. -#endif // _MSC_VER - class GTEST_API_ GoogleTestFailureException : public ::std::runtime_error { public: explicit GoogleTestFailureException(const TestPartResult& failure); }; -#ifdef _MSC_VER -# pragma warning(pop) // Restores the warning state. -#endif // _MSC_VER - #endif // GTEST_HAS_EXCEPTIONS // A helper class for creating scoped traces in user programs. diff --git a/modules/videoio/src/cap_ffmpeg_impl.hpp b/modules/videoio/src/cap_ffmpeg_impl.hpp index 27c374ba0c..fb12902f0c 100644 --- a/modules/videoio/src/cap_ffmpeg_impl.hpp +++ b/modules/videoio/src/cap_ffmpeg_impl.hpp @@ -51,7 +51,7 @@ #define CALC_FFMPEG_VERSION(a,b,c) ( a<<16 | b<<8 | c ) #if defined _MSC_VER && _MSC_VER >= 1200 -#pragma warning( disable: 4244 4510 4512 4610 ) +#pragma warning( disable: 4244 4510 4610 ) #endif #ifdef __GNUC__ @@ -83,7 +83,7 @@ extern "C" { #endif #if defined _MSC_VER && _MSC_VER >= 1200 -#pragma warning( default: 4244 4510 4512 4610 ) +#pragma warning( default: 4244 4510 4610 ) #endif #ifdef NDEBUG diff --git a/modules/videoio/src/cap_msmf.hpp b/modules/videoio/src/cap_msmf.hpp index 87a7476687..cb0514f4af 100644 --- a/modules/videoio/src/cap_msmf.hpp +++ b/modules/videoio/src/cap_msmf.hpp @@ -2084,11 +2084,6 @@ public: // succeed but return a nullptr pointer. By default, the list does not allow nullptr // pointers. -#ifdef _MSC_VER -#pragma warning(push) -#pragma warning(disable: 4127) // constant expression -#endif - template class ComPtrList : public List { @@ -2179,10 +2174,6 @@ protected: } }; -#ifdef _MSC_VER -#pragma warning(pop) -#endif - /* Be sure to declare webcam device capability in manifest For better media capture support, add the following snippet with correct module name to the project manifest (videoio needs DLL activation class factoryentry points):