[PATCH 5/8] lib: define macro NODISCARD

Subject:[PATCH 5/8] lib: define macro NODISCARD

Date:Mon, 23 May 2022 20:38:58 -0300

To:notmuch@notmuchmail.org

Cc:

From:David Bremner


In either C++17 (or later) mode, or when running cppcheck, this can be
used to selectively generate warnings about discarded return values.
---
 lib/notmuch-private.h | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/lib/notmuch-private.h b/lib/notmuch-private.h
index c63cfe5e..1c2290b2 100644
--- a/lib/notmuch-private.h
+++ b/lib/notmuch-private.h
@@ -750,6 +750,12 @@ _notmuch_talloc_steal (const void *new_ctx, const T *ptr)
 #undef talloc_steal
 #define talloc_steal _notmuch_talloc_steal
 #endif
+
+#if __cplusplus >= 201703L || __cppcheck__
+#define NODISCARD [[nodiscard]]
+#else
+#define NODISCARD /**/
+#endif
 #endif
 
 #endif
-- 
2.35.2

_______________________________________________
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-leave@notmuchmail.org

Thread: