From a6d10c8e978feb56423f19f8e41db5dbde636f47 Mon Sep 17 00:00:00 2001 From: qu1ck Date: Fri, 17 Feb 2023 18:13:10 -0800 Subject: [PATCH] Enable warnings on msvc --- 3d-viewer/3d_rendering/raytracing/ray.h | 5 ++- cmake/Warnings.cmake | 53 ++++++++++++++++++++++++- common/kicad_curl/kicad_curl_easy.cpp | 5 ++- common/view/zoom_controller.cpp | 7 ---- include/dsnlexer.h | 2 +- 5 files changed, 60 insertions(+), 12 deletions(-) diff --git a/3d-viewer/3d_rendering/raytracing/ray.h b/3d-viewer/3d_rendering/raytracing/ray.h index ab6a5a45e8..ba46d0ea5b 100644 --- a/3d-viewer/3d_rendering/raytracing/ray.h +++ b/3d-viewer/3d_rendering/raytracing/ray.h @@ -141,8 +141,8 @@ struct RAYSEG2D bool IntersectSegment( const SFVEC2F &aStartA, const SFVEC2F &aEnd_minus_startA, const SFVEC2F &aStartB, const SFVEC2F &aEnd_minus_startB ); -#if(GLM_ARCH != GLM_ARCH_PURE) /* +#if(GLM_ARCH != GLM_ARCH_PURE) struct RAY4 { glm::simdVec4 m_orgX; ///< x coordinate of ray origin @@ -155,9 +155,10 @@ struct RAY4 glm::simdVec4 m_tnear; ///< Start of ray segment glm::simdVec4 m_tfar; ///< End of ray segment -};*/ +}; #endif +*/ #endif // RAY_H diff --git a/cmake/Warnings.cmake b/cmake/Warnings.cmake index 4e35be36f7..d2a5cd9866 100644 --- a/cmake/Warnings.cmake +++ b/cmake/Warnings.cmake @@ -21,7 +21,7 @@ # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA # -# Only configure warnings for Clang and GCC +# Configure warnings for Clang and GCC if( CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang" ) # The SWIG-generated files tend to throw a lot of warnings, so # we do not add the warnings directly to the flags here but instead @@ -189,3 +189,54 @@ if( CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang" ) endif() endif() + +# MSVC specific warnings +if( MSVC ) + set( COMPILER_SUPPORTS_WARNINGS TRUE ) + + # Establish /Wall early and selectively disable some very common warnings in kicad code + # or warnings that really shouldn't be warnings. Also some warnings like implicit fallthrough + # in case statements happen in msvc std lib and despite /external:env:INCLUDE leak + # into build log generating thousands of noise entries. + + # Unlike gcc /Wall actually enables all warnings on msvc. + + # Warnings for C are not enabled since C files are mostly generated + # set( WARN_FLAGS_C "/external:W0 /external:env:INCLUDE /external:I${CMAKE_SOURCE_DIR}/thirdparty /Wall" ) + set( WARN_FLAGS_CXX "/external:W0 /external:env:INCLUDE /external:I${CMAKE_SOURCE_DIR}/thirdparty /Wall" ) + + # disable "function not inlined" + string( APPEND WARN_FLAGS_CXX " /wd4710" ) + # disable "bytes padding added" + string( APPEND WARN_FLAGS_CXX " /wd4820" ) + # disable "unreferenced formal parameter" + string( APPEND WARN_FLAGS_CXX " /wd4100" ) + # disable default/copy/move constructor/assignment implicitly defined as deleted + string( APPEND WARN_FLAGS_CXX " /wd4623 /wd4625 /wd5026 /wd4626 /wd5027" ) + # disable "compiler will insert Spectre mitigation for..." + string( APPEND WARN_FLAGS_CXX " /wd5045" ) + # disable "enumerator in switch for enum is not explicitly handled" + string( APPEND WARN_FLAGS_CXX " /wd4061" ) + # disable "conversion from 'type_1' to 'type_2', signed/unsigned mismatch" + string( APPEND WARN_FLAGS_CXX " /wd4245 /wd4365" ) + # disable "conversion from 'type1' to 'type2', possible loss of data" + string( APPEND WARN_FLAGS_CXX " /wd4242 /wd5219" ) + # disable "no override available for virtual member function, function is hidden" + string( APPEND WARN_FLAGS_CXX " /wd4266" ) + # disable "class has virtual functions, but its (non)trivial destructor is not virtual" + string( APPEND WARN_FLAGS_CXX " /wd5204 /wd4265" ) + # disable "layout of class may have changed from a previous version of the compiler" + string( APPEND WARN_FLAGS_CXX " /wd4371" ) + # disable "relative include path contains '..'" + string( APPEND WARN_FLAGS_CXX " /wd4464" ) + # disable "'const' variable is not used" + string( APPEND WARN_FLAGS_CXX " /wd5264" ) + # disable "implicit fall-through occurs here" in case statement + string( APPEND WARN_FLAGS_CXX " /wd5262" ) + # disable "unreferenced inline function has been removed" + string( APPEND WARN_FLAGS_CXX " /wd4514" ) + # disable "compiler may not enforce left-to-right evaluation order in ..." + string( APPEND WARN_FLAGS_CXX " /wd4868 /wd4866" ) + # disable "XXX is not defined as a preprocessor macro, replacing with '0'" + string( APPEND WARN_FLAGS_CXX " /wd4668" ) +endif() diff --git a/common/kicad_curl/kicad_curl_easy.cpp b/common/kicad_curl/kicad_curl_easy.cpp index b639e91402..0559734cbc 100644 --- a/common/kicad_curl/kicad_curl_easy.cpp +++ b/common/kicad_curl/kicad_curl_easy.cpp @@ -82,6 +82,7 @@ static size_t stream_write_callback( void* aContents, size_t aSize, size_t aNmem return realsize; } +#if LIBCURL_VERSION_NUM >= 0x072000 // 7.32.0 static int xferinfo( void* aProgress, curl_off_t aDLtotal, curl_off_t aDLnow, curl_off_t aULtotal, curl_off_t aULnow ) @@ -100,12 +101,14 @@ static int xferinfo( void* aProgress, curl_off_t aDLtotal, curl_off_t aDLnow, cu return CURLE_OK; } -#if LIBCURL_VERSION_NUM < 0x072000 // 7.32.0 +#else + static int progressinfo( void* aProgress, double aDLtotal, double aDLnow, double aULtotal, double aULnow ) { return xferinfo( aProgress, static_cast( aDLtotal ), static_cast( aDLnow ), static_cast( aULtotal ), static_cast( aULnow ) ); } + #endif diff --git a/common/view/zoom_controller.cpp b/common/view/zoom_controller.cpp index b69bb96693..2985adb973 100644 --- a/common/view/zoom_controller.cpp +++ b/common/view/zoom_controller.cpp @@ -128,10 +128,3 @@ double CONSTANT_ZOOM_CONTROLLER::GetScaleForRotation( int aRotation ) return zoom_scale; } - -// need these until C++17 -constexpr ACCELERATING_ZOOM_CONTROLLER::TIMEOUT ACCELERATING_ZOOM_CONTROLLER::DEFAULT_TIMEOUT; - -constexpr double CONSTANT_ZOOM_CONTROLLER::MAC_SCALE; -constexpr double CONSTANT_ZOOM_CONTROLLER::GTK3_SCALE; -constexpr double CONSTANT_ZOOM_CONTROLLER::MSW_SCALE; diff --git a/include/dsnlexer.h b/include/dsnlexer.h index 2156c12e3d..64b8c013b3 100644 --- a/include/dsnlexer.h +++ b/include/dsnlexer.h @@ -264,7 +264,7 @@ public: */ char SetStringDelimiter( char aStringDelimiter ) { - int old = stringDelimiter; + char old = stringDelimiter; if( specctraMode ) stringDelimiter = aStringDelimiter;