From c1f762b86191066088a429c0118d9a4a544f5987 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20St=C3=B6neberg?= Date: Sat, 23 May 2020 17:42:56 +0200 Subject: [PATCH] disabled some Visual Studio warnings (#2635) --- cli/cli.vcxproj | 16 ++++++++-------- cmake/compilerDefinitions.cmake | 3 +++ cmake/compileroptions.cmake | 20 ++++++++++++++++++++ lib/cppcheck.vcxproj | 16 ++++++++-------- test/testrunner.vcxproj | 8 ++++---- 5 files changed, 43 insertions(+), 20 deletions(-) diff --git a/cli/cli.vcxproj b/cli/cli.vcxproj index 514fa111f..4ea3cc043 100644 --- a/cli/cli.vcxproj +++ b/cli/cli.vcxproj @@ -163,7 +163,7 @@ CPPCHECKLIB_IMPORT;WIN32;_CRT_SECURE_NO_WARNINGS;WIN32_LEAN_AND_MEAN;%(PreprocessorDefinitions) MultiThreadedDebugDLL Level4 - 4251;4482;4512 + 4018;4127;4244;4251;4267;4389;4482;4512;4701;4706;4800 true true stdcpplatest @@ -191,7 +191,7 @@ CPPCHECKLIB_IMPORT;TINYXML2_IMPORT;WIN32;HAVE_RULES;_CRT_SECURE_NO_WARNINGS;WIN32_LEAN_AND_MEAN;TIXML_USE_STL;%(PreprocessorDefinitions) MultiThreadedDebugDLL Level4 - 4251;4482;4512 + 4018;4127;4244;4251;4267;4389;4482;4512;4701;4706;4800 true true stdcpplatest @@ -217,7 +217,7 @@ CPPCHECKLIB_IMPORT;WIN32;_CRT_SECURE_NO_WARNINGS;WIN32_LEAN_AND_MEAN;_WIN64;%(PreprocessorDefinitions) MultiThreadedDebugDLL Level4 - 4251;4482;4512 + 4018;4127;4244;4251;4267;4389;4482;4512;4701;4706;4800 true true stdcpplatest @@ -242,7 +242,7 @@ CPPCHECKLIB_IMPORT;TINYXML2_IMPORT;WIN32;HAVE_RULES;_CRT_SECURE_NO_WARNINGS;WIN32_LEAN_AND_MEAN;_WIN64;%(PreprocessorDefinitions) MultiThreadedDebugDLL Level4 - 4251;4482;4512 + 4018;4127;4244;4251;4267;4389;4482;4512;4701;4706;4800 true true stdcpplatest @@ -271,7 +271,7 @@ Speed true true - 4251;4482;4512 + 4018;4127;4244;4251;4267;4389;4482;4512;4701;4706;4800 true @@ -306,7 +306,7 @@ Speed true true - 4251;4482;4512 + 4018;4127;4244;4251;4267;4389;4482;4512;4701;4706;4800 true @@ -342,7 +342,7 @@ true true true - 4251;4482;4512 + 4018;4127;4244;4251;4267;4389;4482;4512;4701;4706;4800 true @@ -377,7 +377,7 @@ true true true - 4251;4482;4512 + 4018;4127;4244;4251;4267;4389;4482;4512;4701;4706;4800 true diff --git a/cmake/compilerDefinitions.cmake b/cmake/compilerDefinitions.cmake index 6d883064f..d67ed75f2 100644 --- a/cmake/compilerDefinitions.cmake +++ b/cmake/compilerDefinitions.cmake @@ -7,6 +7,9 @@ if (UNIX) endif() add_definitions(-DFILESDIR="${FILESDIR}") endif() +if (MSVC) + add_definitions(-D_CRT_SECURE_NO_WARNINGS) +endif() if (ENABLE_CHECK_INTERNAL) add_definitions(-DCHECK_INTERNAL) endif() diff --git a/cmake/compileroptions.cmake b/cmake/compileroptions.cmake index 3623d903d..0c81c413c 100644 --- a/cmake/compileroptions.cmake +++ b/cmake/compileroptions.cmake @@ -54,6 +54,26 @@ elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang") endif() endif() +if (MSVC) + add_compile_options(/W4) + add_compile_options(/wd4018) # warning C4018: '>': signed/unsigned mismatch + add_compile_options(/wd4127) # warning C4127: conditional expression is constant + add_compile_options(/wd4244) # warning C4244: 'initializing': conversion from 'int' to 'char', possible loss of data + add_compile_options(/wd4251) + # Clang: -Wshorten-64-to-32 -Wimplicit-int-conversion + add_compile_options(/wd4267) # warning C4267: 'return': conversion from 'size_t' to 'int', possible loss of data + add_compile_options(/wd4389) # warning C4389: '==': signed/unsigned mismatch + add_compile_options(/wd4482) + add_compile_options(/wd4512) + add_compile_options(/wd4701) # warning C4701: potentially uninitialized local variable 'err' used + add_compile_options(/wd4706) # warning C4706: assignment within conditional expression + add_compile_options(/wd4800) # warning C4800: 'const SymbolDatabase *' : forcing value to bool 'true' or 'false' (performance warning) + + if (WARNINGS_ARE_ERRORS) + add_compile_options(/WX) + endif() +endif() + # TODO: check if this can be enabled again - also done in Makefile if (CMAKE_SYSTEM_NAME MATCHES "Linux" AND CMAKE_CXX_COMPILER_ID MATCHES "Clang") diff --git a/lib/cppcheck.vcxproj b/lib/cppcheck.vcxproj index 7b0dc06df..75d853787 100644 --- a/lib/cppcheck.vcxproj +++ b/lib/cppcheck.vcxproj @@ -290,7 +290,7 @@ CPPCHECKLIB_EXPORT;TINYXML2_EXPORT;SIMPLECPP_EXPORT;WIN32;_CRT_SECURE_NO_WARNINGS;WIN32_LEAN_AND_MEAN;%(PreprocessorDefinitions) Level4 ..\externals;..\externals\simplecpp;..\externals\tinyxml;%(AdditionalIncludeDirectories) - 4251;4482;4512;4706 + 4018;4127;4244;4251;4267;4389;4482;4512;4701;4706;4800 MultiThreadedDebugDLL Use check.h @@ -321,7 +321,7 @@ xcopy "$(SolutionDir)platforms" "$(OutDir)platforms" /E /I /D /Y CPPCHECKLIB_EXPORT;TINYXML2_EXPORT;SIMPLECPP_EXPORT;WIN32;HAVE_RULES;_CRT_SECURE_NO_WARNINGS;WIN32_LEAN_AND_MEAN;TIXML_USE_STL;%(PreprocessorDefinitions) Level4 ..\externals;..\externals\simplecpp;..\externals\tinyxml;%(AdditionalIncludeDirectories) - 4251;4482;4512;4706 + 4018;4127;4244;4251;4267;4389;4482;4512;4701;4706;4800 MultiThreadedDebugDLL Use check.h @@ -352,7 +352,7 @@ xcopy "$(SolutionDir)platforms" "$(OutDir)platforms" /E /I /D /Y CPPCHECKLIB_EXPORT;TINYXML2_EXPORT;SIMPLECPP_EXPORT;WIN32;_CRT_SECURE_NO_WARNINGS;WIN32_LEAN_AND_MEAN;_WIN64;%(PreprocessorDefinitions) Level4 ..\externals;..\externals\simplecpp;..\externals\tinyxml;%(AdditionalIncludeDirectories) - 4251;4482;4512;4706 + 4018;4127;4244;4251;4267;4389;4482;4512;4701;4706;4800 MultiThreadedDebugDLL Use check.h @@ -381,7 +381,7 @@ xcopy "$(SolutionDir)platforms" "$(OutDir)platforms" /E /I /D /Y CPPCHECKLIB_EXPORT;TINYXML2_EXPORT;SIMPLECPP_EXPORT;WIN32;HAVE_RULES;_CRT_SECURE_NO_WARNINGS;WIN32_LEAN_AND_MEAN;_WIN64;%(PreprocessorDefinitions) Level4 ..\externals;..\externals\simplecpp;..\externals\tinyxml;%(AdditionalIncludeDirectories) - 4251;4482;4512;4706 + 4018;4127;4244;4251;4267;4389;4482;4512;4701;4706;4800 MultiThreadedDebugDLL Use check.h @@ -414,7 +414,7 @@ xcopy "$(SolutionDir)platforms" "$(OutDir)platforms" /E /I /D /Y true true ..\externals;..\externals\simplecpp;..\externals\tinyxml;%(AdditionalIncludeDirectories) - 4251;4482;4512;4706 + 4018;4127;4244;4251;4267;4389;4482;4512;4701;4706;4800 CPPCHECKLIB_EXPORT;TINYXML2_EXPORT;SIMPLECPP_EXPORT;NDEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;WIN32_LEAN_AND_MEAN;%(PreprocessorDefinitions) MultiThreadedDLL @@ -454,7 +454,7 @@ xcopy "$(SolutionDir)platforms" "$(OutDir)platforms" /E /I /D /Y true true ..\externals;..\externals\simplecpp;..\externals\tinyxml;%(AdditionalIncludeDirectories) - 4251;4482;4512;4706 + 4018;4127;4244;4251;4267;4389;4482;4512;4701;4706;4800 CPPCHECKLIB_EXPORT;TINYXML2_EXPORT;SIMPLECPP_EXPORT;NDEBUG;WIN32;HAVE_RULES;_CRT_SECURE_NO_WARNINGS;WIN32_LEAN_AND_MEAN;TIXML_USE_STL;%(PreprocessorDefinitions) MultiThreadedDLL @@ -495,7 +495,7 @@ xcopy "$(SolutionDir)platforms" "$(OutDir)platforms" /E /I /D /Y true true ..\externals;..\externals\simplecpp;..\externals\tinyxml;%(AdditionalIncludeDirectories) - 4251;4482;4512;4706 + 4018;4127;4244;4251;4267;4389;4482;4512;4701;4706;4800 CPPCHECKLIB_EXPORT;TINYXML2_EXPORT;SIMPLECPP_EXPORT;NDEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;WIN32_LEAN_AND_MEAN;_WIN64;%(PreprocessorDefinitions) MultiThreadedDLL @@ -534,7 +534,7 @@ xcopy "$(SolutionDir)platforms" "$(OutDir)platforms" /E /I /D /Y true true ..\externals;..\externals\simplecpp;..\externals\tinyxml;%(AdditionalIncludeDirectories) - 4251;4482;4512;4706 + 4018;4127;4244;4251;4267;4389;4482;4512;4701;4706;4800 CPPCHECKLIB_EXPORT;TINYXML2_EXPORT;SIMPLECPP_EXPORT;NDEBUG;WIN32;HAVE_RULES;_CRT_SECURE_NO_WARNINGS;WIN32_LEAN_AND_MEAN;_WIN64;%(PreprocessorDefinitions) MultiThreadedDLL diff --git a/test/testrunner.vcxproj b/test/testrunner.vcxproj index 910d833d5..56839cd6d 100755 --- a/test/testrunner.vcxproj +++ b/test/testrunner.vcxproj @@ -181,7 +181,7 @@ CPPCHECKLIB_IMPORT;SIMPLECPP_IMPORT;WIN32;_CRT_SECURE_NO_WARNINGS;WIN32_LEAN_AND_MEAN;%(PreprocessorDefinitions) MultiThreadedDebugDLL Level4 - 4251;4482;4512 + 4018;4127;4244;4251;4267;4389;4482;4512;4701;4706;4800 true Use testsuite.h @@ -210,7 +210,7 @@ CPPCHECKLIB_IMPORT;SIMPLECPP_IMPORT;WIN32;_CRT_SECURE_NO_WARNINGS;WIN32_LEAN_AND_MEAN;_WIN64;%(PreprocessorDefinitions) MultiThreadedDebugDLL Level4 - 4251;4482;4512 + 4018;4127;4244;4251;4267;4389;4482;4512;4701;4706;4800 true Use testsuite.h @@ -243,7 +243,7 @@ true true true - 4251;4482;4512 + 4018;4127;4244;4251;4267;4389;4482;4512;4701;4706;4800 true @@ -282,7 +282,7 @@ true true true - 4251;4482;4512 + 4018;4127;4244;4251;4267;4389;4482;4512;4701;4706;4800 true