doc/api/libbabeltrace2/DoxygenLayout.xml: use `topics` tab
[babeltrace.git] / src / common / macros.h
index ad4218c445f98caf104223b1499783f70ceb209d..0f2bc8fb116eda78ac663d748ced56368430d4a6 100644 (file)
@@ -30,27 +30,20 @@ extern "C" {
 #endif
 
 /*
- * Yield `ref`'s value while setting `ref` to NULL.
- *
- * This can be used to give a strong reference to a callee:
- *
- *   add_foo_to_list(list, BT_MOVE_REF(foo));
- *
- * or in a simple assignment:
- *
- *   my_struct->foo = BT_MOVE_REF(foo);
- *
- * When moving a reference in a function call, the reference is given to the
- * callee even if that function call fails, so make sure the called function
- * is written accordingly.
+ * BT_NOEXCEPT: defined to `noexcept` if compiling as C++, else empty.
  */
+#if defined(__cplusplus)
+#define BT_NOEXCEPT noexcept
+#else
+#define BT_NOEXCEPT
+#endif
 
-#define BT_MOVE_REF(ref)               \
-       ({                              \
-               __typeof__(ref) _ref = ref;     \
-               ref = NULL;             \
-               _ref;                   \
-       })
+/* Enable `txt` if developer mode is enabled. */
+#ifdef BT_DEV_MODE
+#define BT_IF_DEV_MODE(txt) txt
+#else
+#define BT_IF_DEV_MODE(txt)
+#endif
 
 /* Wrapper for g_array_index that adds bound checking.  */
 #define bt_g_array_index(a, t, i)              \
@@ -83,6 +76,11 @@ extern "C" {
        ((void) sizeof((void) (_expr1), (void) (_expr2),                \
                (void) (_expr3), (void) (_expr4), (void) (_expr5), 0))
 
+#define BT_DIAG_PUSH _Pragma ("GCC diagnostic push")
+#define BT_DIAG_POP _Pragma ("GCC diagnostic push")
+
+#define BT_DIAG_IGNORE_SHADOW _Pragma("GCC diagnostic ignored \"-Wshadow\"")
+
 #if defined __clang__
 #  if __has_warning("-Wunused-but-set-variable")
 #    define BT_DIAG_IGNORE_UNUSED_BUT_SET_VARIABLE \
This page took 0.02401 seconds and 4 git commands to generate.