]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Provide a way to query debug/release status as a C++ variable.
authorWolfgang Bangerth <bangerth@colostate.edu>
Thu, 27 Feb 2025 22:00:15 +0000 (15:00 -0700)
committerWolfgang Bangerth <bangerth@colostate.edu>
Thu, 27 Feb 2025 22:00:15 +0000 (15:00 -0700)
include/deal.II/base/config.h.in

index 6b47a6fbdcb7fbc21f30462c91e16ff686d5bfde..799dbf6ccbf41e7059c11f288137d74058d726ce 100644 (file)
 #define DEAL_II_VERSION_MINOR @DEAL_II_VERSION_MINOR@
 #define DEAL_II_VERSION_SUBMINOR @DEAL_II_VERSION_SUBMINOR@
 
+/***********************************************************************
+ * Two macro names that we put at the top and bottom of all deal.II files
+ * and that will be expanded to "namespace dealii {" and "}".
+ */
+
+#define DEAL_II_NAMESPACE_OPEN namespace dealii {
+#define DEAL_II_NAMESPACE_CLOSE }
+
+/***********************************************************************
+ * A variable that can be used to query whether we are compiling in
+ * debug or release mode.
+ */
+
+DEAL_II_NAMESPACE_OPEN
+
+/**
+ * An enum type that is used to describe what kind of build has
+ * been used to compile the deal.II library: Namely, whether it is
+ * a debug or a release build.
+ */
+enum class LibraryBuildMode
+{
+  debug,
+  release
+};
+
+/**
+ * A variable that can be queried to determine whether the deal.II
+ * library you are trying to compile against is a debug or a release
+ * mode build.
+ */
+constexpr LibraryBuildMode library_build_mode
+#ifdef DEBUG
+ = LibraryBuildMode::debug;
+#else
+ = LibraryBuildMode::release;
+#endif
+
+
+/**
+ * A function that returns whether we are currently compiling for a debug
+ * build (rather than a release build).
+ */
+constexpr bool running_in_debug_mode()
+{
+  return (library_build_mode == LibraryBuildMode::debug);
+}
+
+
+DEAL_II_NAMESPACE_CLOSE
+
 
 /***********************************************************************
  * Configured deal.II features:
 
 #cmakedefine DEAL_II_MPI_WITH_DEVICE_SUPPORT
 
-/***********************************************************************
- * Two macro names that we put at the top and bottom of all deal.II files
- * and that will be expanded to "namespace dealii {" and "}".
- */
-
-#define DEAL_II_NAMESPACE_OPEN namespace dealii {
-#define DEAL_II_NAMESPACE_CLOSE }
-
 /***********************************************************************
  * Two macros to guard external header includes.
  *

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.