summaryrefslogtreecommitdiffstats
path: root/include/zix/attributes.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/zix/attributes.h')
-rw-r--r--include/zix/attributes.h13
1 files changed, 9 insertions, 4 deletions
diff --git a/include/zix/attributes.h b/include/zix/attributes.h
index 518e5fb..249e6a6 100644
--- a/include/zix/attributes.h
+++ b/include/zix/attributes.h
@@ -38,27 +38,32 @@
# define ZIX_PURE_FUNC __attribute__((pure))
# define ZIX_CONST_FUNC __attribute__((const))
# define ZIX_MALLOC_FUNC __attribute__((malloc))
+# define ZIX_NODISCARD __attribute__((warn_unused_result))
#else
# define ZIX_ALWAYS_INLINE_FUNC ///< Should absolutely always be inlined
# define ZIX_PURE_FUNC ///< Only reads memory
# define ZIX_CONST_FUNC ///< Only reads its parameters
-# define ZIX_MALLOC_FUNC ///< Allocates memory
+# define ZIX_MALLOC_FUNC ///< Allocates memory with no pointers in it
+# define ZIX_NODISCARD ///< Returns a value that must be used
#endif
/// A pure function in the public API that only reads memory
#define ZIX_PURE_API \
ZIX_API \
- ZIX_PURE_FUNC
+ ZIX_PURE_FUNC \
+ ZIX_NODISCARD
/// A const function in the public API that is pure and only reads parameters
#define ZIX_CONST_API \
ZIX_API \
- ZIX_CONST_FUNC
+ ZIX_CONST_FUNC \
+ ZIX_NODISCARD
/// A malloc function in the public API that returns allocated memory
#define ZIX_MALLOC_API \
ZIX_API \
- ZIX_MALLOC_FUNC
+ ZIX_MALLOC_FUNC \
+ ZIX_NODISCARD
// Printf-like format functions
#ifdef __GNUC__