From 7d95c55eafc80bdfbd12ea5ffa29fa35d76f0e1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Thu, 28 May 2026 13:10:28 +0200 Subject: [PATCH] Fix unused variable warnings on a no-assert build. --- src/Magnum/GL/Implementation/RendererState.cpp | 3 +++ src/Magnum/Platform/Sdl2Application.cpp | 6 ++++++ src/Magnum/Trade/MaterialData.cpp | 6 +++++- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/Magnum/GL/Implementation/RendererState.cpp b/src/Magnum/GL/Implementation/RendererState.cpp index f79da2e2b..e4d622298 100644 --- a/src/Magnum/GL/Implementation/RendererState.cpp +++ b/src/Magnum/GL/Implementation/RendererState.cpp @@ -380,6 +380,9 @@ void RendererState::applyPixelStorageInternal(const Magnum::PixelStorage& storag void RendererState::applyCompressedPixelStorageInternal(const CompressedPixelStorage& storage, const Vector3i& blockSize, const Int blockDataSize, const bool isUnpack) { #ifdef MAGNUM_TARGET_GLES + #ifdef CORRADE_NO_ASSERT + static_cast(storage); + #endif CORRADE_ASSERT(storage == CompressedPixelStorage{}, "GL: non-default CompressedPixelStorage parameters are not supported in OpenGL ES or WebGL", ); static_cast(blockSize); diff --git a/src/Magnum/Platform/Sdl2Application.cpp b/src/Magnum/Platform/Sdl2Application.cpp index 73e7c9190..c2d7d46f5 100644 --- a/src/Magnum/Platform/Sdl2Application.cpp +++ b/src/Magnum/Platform/Sdl2Application.cpp @@ -378,6 +378,12 @@ Vector2 Sdl2Application::dpiScalingInternal(const Implementation::Sdl2DpiScaling CORRADE_INTERNAL_ASSERT(dpiScalingPolicy == Implementation::Sdl2DpiScalingPolicy::Virtual || dpiScalingPolicy == Implementation::Sdl2DpiScalingPolicy::Physical); #else CORRADE_INTERNAL_ASSERT(dpiScalingPolicy == Implementation::Sdl2DpiScalingPolicy::Physical); + /* On Emscripten the DPI scaling policy is only used in the above + assertion, otherwise it's unused. Suppressing an unused variable warning + instead of adding even more ifdefs to make the code easier to read. */ + #if defined(CORRADE_TARGET_EMSCRIPTEN) && defined(CORRADE_NO_ASSERT) + static_cast(dpiScalingPolicy); + #endif #endif /* Take device pixel ratio on Emscripten */ diff --git a/src/Magnum/Trade/MaterialData.cpp b/src/Magnum/Trade/MaterialData.cpp index 7117e22c8..68a924cc2 100644 --- a/src/Magnum/Trade/MaterialData.cpp +++ b/src/Magnum/Trade/MaterialData.cpp @@ -299,7 +299,11 @@ MaterialData::MaterialData(const MaterialTypes types, Containers::Array 1) for(std::size_t j = begin + 1; j != end; ++j) { if(_data[j - 1].name() < _data[j].name()) continue; - std::sort(_data + begin, _data + end, [i](const MaterialAttributeData& a, const MaterialAttributeData& b) { + std::sort(_data + begin, _data + end, [ + #ifndef CORRADE_NO_ASSERT + i + #endif + ](const MaterialAttributeData& a, const MaterialAttributeData& b) { /* Need to check here (instead of in the outer for loop) as we exit the loop right after the sort and thus duplicates that occur after the first non-sorted pair wouldn't get detected.