From fe0cce731ba6a6c996be0cf543bcabe3e3a5e03d Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Mon, 3 Apr 2023 14:55:16 +0200 Subject: [PATCH] Explicitly disable certain warnings in code This code is good as-is, they cannot be adjusted to suppress the warnings while still guaranteeing its functionality. --- r5dev/engine/host_state.cpp | 5 +++++ r5dev/public/utility/sigcache.cpp | 3 +++ r5dev/squirrel/sqvm.cpp | 3 +++ r5dev/tier1/strtools.cpp | 3 +++ 4 files changed, 14 insertions(+) diff --git a/r5dev/engine/host_state.cpp b/r5dev/engine/host_state.cpp index c9b48eb4..09e6495a 100644 --- a/r5dev/engine/host_state.cpp +++ b/r5dev/engine/host_state.cpp @@ -75,11 +75,16 @@ void CHostState::FrameUpdate(CHostState* pHostState, double flCurrentTime, float #endif // !DEDICATED HostStates_t oldState{}; + + // Disable "warning C4611: interaction between '_setjmp' and C++ object destruction is non-portable" +#pragma warning(push) +#pragma warning(disable : 4611) if (setjmp(*host_abortserver)) { g_pHostState->Init(); return; } +#pragma warning(pop) else { #ifndef CLIENT_DLL diff --git a/r5dev/public/utility/sigcache.cpp b/r5dev/public/utility/sigcache.cpp index 3076fc79..a4c97aec 100644 --- a/r5dev/public/utility/sigcache.cpp +++ b/r5dev/public/utility/sigcache.cpp @@ -144,7 +144,10 @@ bool CSigCache::LoadCache(const string& svCacheFile) return false; } +#pragma warning(push) // Disabled type conversion warning, as it is possible +#pragma warning(disable : 4244) // for Protobuf to migrate this code to feature size_t. if (!m_Cache.ParseFromArray(pDstBuf.get(), header.m_nBlobSizeMem)) +#pragma warning(pop) { return false; } diff --git a/r5dev/squirrel/sqvm.cpp b/r5dev/squirrel/sqvm.cpp index 2fc20d1b..bb3339d2 100644 --- a/r5dev/squirrel/sqvm.cpp +++ b/r5dev/squirrel/sqvm.cpp @@ -34,7 +34,10 @@ SQRESULT SQVM_PrintFunc(HSQUIRRELVM v, SQChar* fmt, ...) eDLL_T remoteContext; // We use the sqvm pointer as index for SDK usage as the function prototype has to match assembly. // The compiler 'pointer truncation' warning couldn't be avoided, but it's safe to ignore it. +#pragma warning(push) +#pragma warning(disable : 4302 4311) switch (static_cast(reinterpret_cast(v))) +#pragma warning(pop) { case SQCONTEXT::SERVER: remoteContext = eDLL_T::SCRIPT_SERVER; diff --git a/r5dev/tier1/strtools.cpp b/r5dev/tier1/strtools.cpp index 02625bb7..88a16ad1 100644 --- a/r5dev/tier1/strtools.cpp +++ b/r5dev/tier1/strtools.cpp @@ -629,8 +629,11 @@ V_MakeAbsolutePath(char* pOut, size_t outLen, const char* pPath, const char* pSt } #else { +#pragma warning(push) // Disabled type conversion warning, as some implementations of '_getcwd' take a size_t. +#pragma warning(disable : 4267) if (!_getcwd(pOut, outLen)) Error(eDLL_T::COMMON, EXIT_FAILURE, "V_MakeAbsolutePath: _getcwd failed."); +#pragma warning(pop) } #endif