From 8754d8790096c779ea988141f2d1fe5694dd8aef Mon Sep 17 00:00:00 2001 From: reuk Date: Thu, 5 Sep 2024 11:30:55 +0100 Subject: [PATCH] Windows: Fix build warnings when JUCE_DISABLE_ASSERTIONS is set --- .../processors/juce_AudioPluginInstance.cpp | 4 ++-- .../juce_graphics/contexts/juce_GraphicsContext.cpp | 10 +++++----- modules/juce_graphics/native/juce_DirectX_windows.h | 6 ++---- .../juce_gui_basics/native/juce_Windowing_windows.cpp | 3 +-- modules/juce_opengl/juce_opengl.cpp | 4 ++-- modules/juce_opengl/opengl/juce_OpenGLContext.cpp | 2 +- 6 files changed, 13 insertions(+), 16 deletions(-) diff --git a/modules/juce_audio_processors/processors/juce_AudioPluginInstance.cpp b/modules/juce_audio_processors/processors/juce_AudioPluginInstance.cpp index e23be2baef..106c6a832d 100644 --- a/modules/juce_audio_processors/processors/juce_AudioPluginInstance.cpp +++ b/modules/juce_audio_processors/processors/juce_AudioPluginInstance.cpp @@ -263,7 +263,7 @@ void AudioPluginInstance::addHostedParameterGroup (std::unique_ptrgetParameters (true)) { - jassert (dynamic_cast (param) != nullptr); + jassertquiet (dynamic_cast (param) != nullptr); } #endif @@ -277,7 +277,7 @@ void AudioPluginInstance::setHostedParameterTree (AudioProcessorParameterGroup g // garbage and your host will crash and burn for (auto* param : group.getParameters (true)) { - jassert (dynamic_cast (param) != nullptr); + jassertquiet (dynamic_cast (param) != nullptr); } #endif diff --git a/modules/juce_graphics/contexts/juce_GraphicsContext.cpp b/modules/juce_graphics/contexts/juce_GraphicsContext.cpp index 68c49ab8e6..0fb76ee926 100644 --- a/modules/juce_graphics/contexts/juce_GraphicsContext.cpp +++ b/modules/juce_graphics/contexts/juce_GraphicsContext.cpp @@ -100,12 +100,12 @@ namespace Rectangle coordsToRectangle (Type x, Type y, Type w, Type h) noexcept { #if JUCE_DEBUG - const int maxVal = 0x3fffffff; + constexpr int maxVal = 0x3fffffff; - jassert ((int) x >= -maxVal && (int) x <= maxVal - && (int) y >= -maxVal && (int) y <= maxVal - && (int) w >= 0 && (int) w <= maxVal - && (int) h >= 0 && (int) h <= maxVal); + jassertquiet ((int) x >= -maxVal && (int) x <= maxVal + && (int) y >= -maxVal && (int) y <= maxVal + && (int) w >= 0 && (int) w <= maxVal + && (int) h >= 0 && (int) h <= maxVal); #endif return { x, y, w, h }; diff --git a/modules/juce_graphics/native/juce_DirectX_windows.h b/modules/juce_graphics/native/juce_DirectX_windows.h index 5f4b9ece46..0c2e23eb9f 100644 --- a/modules/juce_graphics/native/juce_DirectX_windows.h +++ b/modules/juce_graphics/native/juce_DirectX_windows.h @@ -421,14 +421,12 @@ struct Direct2DBitmap JUCE_D2DMETRICS_SCOPED_ELAPSED_TIME (Direct2DMetricsHub::getInstance()->imageContextMetrics, createBitmapTime); - #if JUCE_DEBUG // Verify that the GPU can handle a bitmap of this size // // If you need a bitmap larger than this, you'll need to either split it up into multiple bitmaps // or use a software image (see SoftwareImageType). - auto maxBitmapSize = deviceContext->GetMaximumBitmapSize(); - jassert (size.width <= maxBitmapSize && size.height <= maxBitmapSize); - #endif + const auto maxBitmapSize = deviceContext->GetMaximumBitmapSize(); + jassertquiet (size.width <= maxBitmapSize && size.height <= maxBitmapSize); const auto pixelFormat = D2D1::PixelFormat (format == Image::SingleChannel ? DXGI_FORMAT_A8_UNORM diff --git a/modules/juce_gui_basics/native/juce_Windowing_windows.cpp b/modules/juce_gui_basics/native/juce_Windowing_windows.cpp index 2bb35c82b1..7a1a7de954 100644 --- a/modules/juce_gui_basics/native/juce_Windowing_windows.cpp +++ b/modules/juce_gui_basics/native/juce_Windowing_windows.cpp @@ -69,7 +69,6 @@ void* getUser32Function (const char*); #if JUCE_DEBUG int numActiveScopedDpiAwarenessDisablers = 0; - static bool isInScopedDPIAwarenessDisabler() { return numActiveScopedDpiAwarenessDisablers > 0; } extern HWND juce_messageWindowHandle; #endif @@ -2465,7 +2464,7 @@ private: // You normally want these to match otherwise timer events and async messages will happen // in a different context to normal HWND messages which can cause issues with UI scaling. jassert (isPerMonitorDPIAwareWindow (hwnd) == isPerMonitorDPIAwareWindow (juce_messageWindowHandle) - || isInScopedDPIAwarenessDisabler()); + || numActiveScopedDpiAwarenessDisablers > 0); #endif if (hwnd != nullptr) diff --git a/modules/juce_opengl/juce_opengl.cpp b/modules/juce_opengl/juce_opengl.cpp index c20886ffe2..9023896a08 100644 --- a/modules/juce_opengl/juce_opengl.cpp +++ b/modules/juce_opengl/juce_opengl.cpp @@ -126,7 +126,7 @@ JUCE_GL_EXTENSION_FUNCTIONS JUCE_GL_VERTEXBUFFER_FUNCTIONS #undef X -#if JUCE_DEBUG && ! defined (JUCE_CHECK_OPENGL_ERROR) +#if JUCE_DEBUG && ! JUCE_DISABLE_ASSERTIONS && ! defined (JUCE_CHECK_OPENGL_ERROR) static const char* getGLErrorMessage (const GLenum e) noexcept { switch (e) @@ -197,7 +197,7 @@ static bool checkPeerIsValid (OpenGLContext* context) return false; } -static void checkGLError (const char* file, const int line) +static void checkGLError ([[maybe_unused]] const char* file, [[maybe_unused]] const int line) { for (;;) { diff --git a/modules/juce_opengl/opengl/juce_OpenGLContext.cpp b/modules/juce_opengl/opengl/juce_OpenGLContext.cpp index 8152d44bb0..2a933d415a 100644 --- a/modules/juce_opengl/opengl/juce_OpenGLContext.cpp +++ b/modules/juce_opengl/opengl/juce_OpenGLContext.cpp @@ -637,7 +637,7 @@ public: gl::loadFunctions(); - #if JUCE_DEBUG + #if JUCE_DEBUG && ! JUCE_DISABLE_ASSERTIONS if (getOpenGLVersion() >= Version { 4, 3 } && glDebugMessageCallback != nullptr) { glEnable (GL_DEBUG_OUTPUT);