]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Assert: combine the two release build definitions.
authorDavid Wells <drwells@email.unc.edu>
Thu, 29 May 2025 14:34:55 +0000 (10:34 -0400)
committerDavid Wells <drwells@email.unc.edu>
Thu, 29 May 2025 15:14:57 +0000 (11:14 -0400)
The 'if (false)' trick should work (and avoid unused variable warnings)
with all supported compilers and language standards.

include/deal.II/base/exception_macros.h

index 1237828e6c1a9d5a867284dce9f4bde2ef7635d9..174c8d2ac2f5c127ead1181dafdc80532ff2d818 100644 (file)
 #    endif /*ifdef KOKKOS_ACTIVE_EXECUTION_MEMORY_SPACE_HOST*/
 #  endif   /*KOKKOS_ACTIVE_EXECUTION_MEMORY_SPACE_HOST*/
 #else      /*ifdef DEBUG*/
-#  ifdef DEAL_II_HAVE_CXX20
-/*
- * 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. Notably, this approach works with C++20 onwards.
- */
-#    define Assert(cond, exc)                                                 \
-      do                                                                      \
-        {                                                                     \
-          std::remove_reference_t<decltype(cond)> *dealii_assert_variable_a = \
-            nullptr;                                                          \
-          std::remove_reference_t<decltype(exc)> *dealii_assert_variable_b =  \
-            nullptr;                                                          \
-          (void)dealii_assert_variable_a;                                     \
-          (void)dealii_assert_variable_b;                                     \
-        }                                                                     \
-      while (false)
-#  else
-#    define Assert(cond, exc) \
-      do                      \
-        {                     \
-          if (false)          \
-            if (!(cond))      \
-              {               \
-              }               \
-        }                     \
-      while (false)
-#  endif
+#  define Assert(cond, exc) \
+    do                      \
+      {                     \
+        if (false)          \
+          if (!(cond))      \
+            {               \
+            }               \
+      }                     \
+    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.