From: Matthias Maier Date: Tue, 13 Aug 2024 15:50:44 +0000 (-0500) Subject: Assert Macro: avoid unused parameters (etc.) warnings by always using macro arguments X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ffdd9a82d8b400f3aa86ed2e8ac07f8c2f444784;p=dealii.git Assert Macro: avoid unused parameters (etc.) warnings by always using macro arguments --- 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*/