From 2d6d510ffa218363e49f10bd53541d31a37bd487 Mon Sep 17 00:00:00 2001 From: Itms Date: Sat, 5 Jul 2025 16:04:08 +0200 Subject: [PATCH] Hide compiler warnings from external includes --- build/premake/premake5.lua | 10 +++-- source/gui/CGUI.cpp | 6 --- source/gui/CGUISetting.h | 9 +---- source/gui/GUIManager.cpp | 6 --- source/gui/tests/test_GuiManager.h | 6 --- source/ps/XMB/XMBStorage.h | 8 ---- source/scriptinterface/JSON.cpp | 15 ------- source/scriptinterface/Promises.h | 7 ---- source/scriptinterface/ScriptExtraHeaders.h | 28 ------------- source/scriptinterface/ScriptForward.h | 28 ------------- source/scriptinterface/ScriptRequest.h | 15 ------- source/scriptinterface/ScriptTypes.h | 44 --------------------- source/scriptinterface/StructuredClone.cpp | 15 ------- 13 files changed, 7 insertions(+), 190 deletions(-) diff --git a/build/premake/premake5.lua b/build/premake/premake5.lua index 3d83801c12..97d104b6e5 100644 --- a/build/premake/premake5.lua +++ b/build/premake/premake5.lua @@ -234,10 +234,6 @@ function project_set_build_flags() end sanitize(sanitizers) - if os.istarget("windows") then - warnings "Extra" - end - -- disable Windows debug heap, since it makes malloc/free hugely slower when -- running inside a debugger if os.istarget("windows") then @@ -286,6 +282,9 @@ function project_set_build_flags() defines { "CONFIG2_DAP_INTERFACE=0" } end + -- hide warnings caused by library includes + externalwarnings "Off" + -- various platform-specific build flags if os.istarget("windows") then @@ -299,6 +298,9 @@ function project_set_build_flags() -- use native wchar_t type (not typedef to unsigned short) nativewchar "on" + -- enable most of the standard warnings + warnings "Extra" + -- FIXME: conversion warnings, should add -Wconversion to gcc and clang flags as well disablewarnings { "4267" } diff --git a/source/gui/CGUI.cpp b/source/gui/CGUI.cpp index 8621cbc955..84260f59e0 100644 --- a/source/gui/CGUI.cpp +++ b/source/gui/CGUI.cpp @@ -58,13 +58,7 @@ #include #include -#if MSC_VERSION -# pragma warning(push, 1) -#endif #include -#if MSC_VERSION -# pragma warning(pop) -#endif #include #include #include diff --git a/source/gui/CGUISetting.h b/source/gui/CGUISetting.h index e5a9e17017..a06815f6a5 100644 --- a/source/gui/CGUISetting.h +++ b/source/gui/CGUISetting.h @@ -21,15 +21,8 @@ #include "lib/code_annotation.h" #include "ps/CStr.h" -#if MSC_VERSION -# pragma warning(push, 1) -# pragma warning(disable: 4068) -# pragma warning(disable: 4100) -#endif #include -#if MSC_VERSION -# pragma warning(pop) -#endif + #include class IGUIObject; diff --git a/source/gui/GUIManager.cpp b/source/gui/GUIManager.cpp index 00e6f756b6..78a794f98c 100644 --- a/source/gui/GUIManager.cpp +++ b/source/gui/GUIManager.cpp @@ -47,13 +47,7 @@ #include #include #include -#if MSC_VERSION -# pragma warning(push, 1) -#endif #include -#if MSC_VERSION -# pragma warning(pop) -#endif #include #include #include diff --git a/source/gui/tests/test_GuiManager.h b/source/gui/tests/test_GuiManager.h index 7f990c70de..423b425b0b 100644 --- a/source/gui/tests/test_GuiManager.h +++ b/source/gui/tests/test_GuiManager.h @@ -54,13 +54,7 @@ #include #include -#if MSC_VERSION -# pragma warning(push, 1) -#endif #include "js/Promise.h" -#if MSC_VERSION -# pragma warning(pop) -#endif class TestGuiManager : public CxxTest::TestSuite { diff --git a/source/ps/XMB/XMBStorage.h b/source/ps/XMB/XMBStorage.h index a94fec358d..9bb4375624 100644 --- a/source/ps/XMB/XMBStorage.h +++ b/source/ps/XMB/XMBStorage.h @@ -21,15 +21,7 @@ #include "lib/types.h" #include -#if MSC_VERSION -# pragma warning(push, 1) -# pragma warning(disable: 4068) -# pragma warning(disable: 4100) -#endif #include -#if MSC_VERSION -# pragma warning(pop) -#endif #include #include #include diff --git a/source/scriptinterface/JSON.cpp b/source/scriptinterface/JSON.cpp index 5f95160246..da460e27a8 100644 --- a/source/scriptinterface/JSON.cpp +++ b/source/scriptinterface/JSON.cpp @@ -29,23 +29,8 @@ #include -// Ignore warnings in SM headers. -#if GCC_VERSION || CLANG_VERSION -# pragma GCC diagnostic push -# pragma GCC diagnostic ignored "-Wunused-parameter" -# pragma GCC diagnostic ignored "-Wnon-virtual-dtor" -#elif MSC_VERSION -# pragma warning(push, 1) -#endif - #include "js/JSON.h" -#if GCC_VERSION || CLANG_VERSION -# pragma GCC diagnostic pop -#elif MSC_VERSION -# pragma warning(pop) -#endif - bool Script::ParseJSON(const ScriptRequest& rq, const std::string& string_utf8, JS::MutableHandleValue out) { std::wstring attrsW = wstring_from_utf8(string_utf8); diff --git a/source/scriptinterface/Promises.h b/source/scriptinterface/Promises.h index a144b4487b..a99e43af90 100644 --- a/source/scriptinterface/Promises.h +++ b/source/scriptinterface/Promises.h @@ -18,14 +18,7 @@ #ifndef INCLUDED_SCRIPTINTERFACE_JOBQUEUE #define INCLUDED_SCRIPTINTERFACE_JOBQUEUE -#if MSC_VERSION -# pragma warning(push, 1) -# pragma warning(disable: 4068) -#endif #include "js/Promise.h" -#if MSC_VERSION -# pragma warning(pop) -#endif #include diff --git a/source/scriptinterface/ScriptExtraHeaders.h b/source/scriptinterface/ScriptExtraHeaders.h index 172fda064c..8105c234d6 100644 --- a/source/scriptinterface/ScriptExtraHeaders.h +++ b/source/scriptinterface/ScriptExtraHeaders.h @@ -24,24 +24,6 @@ #include "scriptinterface/ScriptTypes.h" -// Ignore some harmless warnings -#if GCC_VERSION -# pragma GCC diagnostic push -# pragma GCC diagnostic ignored "-Wunused-parameter" -# pragma GCC diagnostic ignored "-Wredundant-decls" -# pragma GCC diagnostic ignored "-Wnon-virtual-dtor" -#endif -#if CLANG_VERSION -# pragma clang diagnostic push -# pragma clang diagnostic ignored "-Wmismatched-tags" -#endif -#if MSC_VERSION -// reduce the warning level for the SpiderMonkey headers -# pragma warning(push, 1) -// ignore C4291 in -# pragma warning(disable: 4291) -#endif - // Redefine signbit to fix build error in GCC #ifndef signbit # define signbit std::signbit @@ -68,14 +50,4 @@ #undef signbit -#if MSC_VERSION -# pragma warning(pop) -#endif -#if CLANG_VERSION -# pragma clang diagnostic pop -#endif -#if GCC_VERSION -# pragma GCC diagnostic pop -#endif - #endif // INCLUDED_SCRIPTEXTRAHEADERS diff --git a/source/scriptinterface/ScriptForward.h b/source/scriptinterface/ScriptForward.h index fb7599056b..476af48aa7 100644 --- a/source/scriptinterface/ScriptForward.h +++ b/source/scriptinterface/ScriptForward.h @@ -18,23 +18,6 @@ #ifndef INCLUDED_SCRIPTFORWARD #define INCLUDED_SCRIPTFORWARD - -// Ignore some harmless warnings -#if GCC_VERSION -# pragma GCC diagnostic push -# pragma GCC diagnostic ignored "-Wunused-parameter" -#endif -#if CLANG_VERSION -# pragma clang diagnostic push -# pragma clang diagnostic ignored "-Wunused-parameter" -#endif -#if MSC_VERSION -# pragma warning(push, 1) -# pragma warning(disable: 4100) -# pragma warning(disable: 4068) -#endif - - #include "js/TypeDecls.h" // Complete with a few additional ones. @@ -51,15 +34,4 @@ class ScriptContext; class ScriptInterface; class ScriptRequest; -#if GCC_VERSION -# pragma GCC diagnostic pop -#endif -#if CLANG_VERSION -# pragma clang diagnostic pop -#endif -#if MSC_VERSION -# pragma warning(pop) -#endif - - #endif // INCLUDED_SCRIPTFORWARD diff --git a/source/scriptinterface/ScriptRequest.h b/source/scriptinterface/ScriptRequest.h index e5c834fc92..9fe0e1002a 100644 --- a/source/scriptinterface/ScriptRequest.h +++ b/source/scriptinterface/ScriptRequest.h @@ -20,23 +20,8 @@ #include "scriptinterface/ScriptForward.h" -// Ignore warnings in SM headers. -#if GCC_VERSION || CLANG_VERSION -# pragma GCC diagnostic push -# pragma GCC diagnostic ignored "-Wunused-parameter" -# pragma GCC diagnostic ignored "-Wnon-virtual-dtor" -#elif MSC_VERSION -# pragma warning(push, 1) -#endif - #include "js/RootingAPI.h" -#if GCC_VERSION || CLANG_VERSION -# pragma GCC diagnostic pop -#elif MSC_VERSION -# pragma warning(pop) -#endif - #include class ScriptInterface; diff --git a/source/scriptinterface/ScriptTypes.h b/source/scriptinterface/ScriptTypes.h index cce674f772..5f4ddf37dd 100644 --- a/source/scriptinterface/ScriptTypes.h +++ b/source/scriptinterface/ScriptTypes.h @@ -32,53 +32,9 @@ # endif #endif -// Ignore some harmless warnings -#if GCC_VERSION -# pragma GCC diagnostic push -# pragma GCC diagnostic ignored "-Wunused-parameter" -# pragma GCC diagnostic ignored "-Wredundant-decls" -# pragma GCC diagnostic ignored "-Wundef" // Some versions of GCC will still print warnings (see http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53431). -# pragma GCC diagnostic ignored "-Wnon-virtual-dtor" -# pragma GCC diagnostic ignored "-Wignored-qualifiers" -# pragma GCC diagnostic ignored "-Wextra" -#endif -#if CLANG_VERSION -# pragma clang diagnostic push -# pragma clang diagnostic ignored "-Wuninitialized" -# pragma clang diagnostic ignored "-Wc++11-extensions" -# pragma clang diagnostic ignored "-Wignored-qualifiers" -# pragma clang diagnostic ignored "-Wmismatched-tags" -// Ugly hack to deal with macro redefinitions from libc++ -# ifdef nullptr -# undef nullptr -# endif -# ifdef decltype -# undef decltype -# endif -#endif -#if MSC_VERSION -// reduce the warning level for the SpiderMonkey headers -# pragma warning(push, 1) -// ignore C4291 in -# pragma warning(disable: 4291) -// ignore C4068 in -# pragma warning(disable: 4068) -#endif - #include "jspubtd.h" #include "jsapi.h" -// restore user flags and re-enable the warnings disabled a few lines above -#if MSC_VERSION -# pragma warning(pop) -#endif -#if CLANG_VERSION -# pragma clang diagnostic pop -#endif -#if GCC_VERSION -# pragma GCC diagnostic pop -#endif - #if MOZJS_MAJOR_VERSION != 115 #error Your compiler is trying to use an incorrect major version of the \ SpiderMonkey library. The SpiderMonkey API is subject to changes, and the \ diff --git a/source/scriptinterface/StructuredClone.cpp b/source/scriptinterface/StructuredClone.cpp index a761f9fd9d..78c58743a7 100644 --- a/source/scriptinterface/StructuredClone.cpp +++ b/source/scriptinterface/StructuredClone.cpp @@ -23,23 +23,8 @@ #include "ScriptRequest.h" #include "StructuredClone.h" -// Ignore warnings in SM headers. -#if GCC_VERSION || CLANG_VERSION -# pragma GCC diagnostic push -# pragma GCC diagnostic ignored "-Wunused-parameter" -# pragma GCC diagnostic ignored "-Wnon-virtual-dtor" -#elif MSC_VERSION -# pragma warning(push, 1) -#endif - #include "js/StructuredClone.h" -#if GCC_VERSION || CLANG_VERSION -# pragma GCC diagnostic pop -#elif MSC_VERSION -# pragma warning(pop) -#endif - Script::StructuredClone Script::WriteStructuredClone(const ScriptRequest& rq, JS::HandleValue v) { Script::StructuredClone ret(new JSStructuredCloneData(JS::StructuredCloneScope::SameProcess));