]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Assert Macro: avoid unused parameters (etc.) warnings by always using macro arguments 17510/head
authorMatthias Maier <tamiko@43-1.org>
Tue, 13 Aug 2024 15:50:44 +0000 (10:50 -0500)
committerMatthias Maier <tamiko@43-1.org>
Tue, 13 Aug 2024 16:22:47 +0000 (11:22 -0500)
include/deal.II/base/exceptions.h

index e21e20835821528b8a736d7e30ccbd57e535b6eb..b6c5d578b30db4ba8d3fde43fecfe1ab9582bf4a 100644 (file)
@@ -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<decltype(cond)>::type *deal_ii_asser_a; \
+        typename std::remove_reference<decltype(exc)>::type  *deal_ii_asser_b; \
+        (void)deal_ii_asser_a;                                                 \
+        (void)deal_ii_asser_b;                                                 \
+      }                                                                        \
     while (false)
+
 #endif /*ifdef DEBUG*/
 
 

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.