From ffdd9a82d8b400f3aa86ed2e8ac07f8c2f444784 Mon Sep 17 00:00:00 2001 From: Matthias Maier Date: Tue, 13 Aug 2024 10:50:44 -0500 Subject: [PATCH] Assert Macro: avoid unused parameters (etc.) warnings by always using macro arguments --- include/deal.II/base/exceptions.h | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/include/deal.II/base/exceptions.h b/include/deal.II/base/exceptions.h index e21e208358..b6c5d578b3 100644 --- a/include/deal.II/base/exceptions.h +++ b/include/deal.II/base/exceptions.h @@ -1659,11 +1659,22 @@ namespace deal_II_exceptions # endif /*ifdef KOKKOS_ACTIVE_EXECUTION_MEMORY_SPACE_HOST*/ # endif /*KOKKOS_ACTIVE_EXECUTION_MEMORY_SPACE_HOST*/ #else /*ifdef DEBUG*/ -# define Assert(cond, exc) \ - do \ - { \ - } \ +/* + * In order to avoid unused parameters (etc.) warnings we need to use cond + * and exc without actually evaluating the expression and generating code. + * We accomplish this by using decltype(...) and create a dummy pointer + * with these signatures. + */ +# define Assert(cond, exc) \ + do \ + { \ + typename std::remove_reference::type *deal_ii_asser_a; \ + typename std::remove_reference::type *deal_ii_asser_b; \ + (void)deal_ii_asser_a; \ + (void)deal_ii_asser_b; \ + } \ while (false) + #endif /*ifdef DEBUG*/ -- 2.39.5