]> git.ozlabs.org Git - ccan/blobdiff - ccan/compiler/compiler.h
gitify the tree, especially the web makefile.
[ccan] / ccan / compiler / compiler.h
index 242ef84d133ddb65ea378bdfcc6585a7f46d7bd8..49088ac799e6f0ba9772afde55d8a9fdd421f71d 100644 (file)
 /* If we don't know, assume it's not. */
 #define IS_COMPILE_CONSTANT(expr) 0
 #endif
+
+#if HAVE_WARN_UNUSED_RESULT
+/**
+ * WARN_UNUSED_RESULT - warn if a function return value is unused.
+ *
+ * Used to mark a function where it is extremely unlikely that the caller
+ * can ignore the result, eg realloc().
+ *
+ * Example:
+ * // buf param may be freed by this; need return value!
+ * static char *WARN_UNUSED_RESULT enlarge(char *buf, unsigned *size)
+ * {
+ *     return realloc(buf, (*size) *= 2);
+ * }
+ */
+#define WARN_UNUSED_RESULT __attribute__((warn_unused_result))
+#else
+#define WARN_UNUSED_RESULT
+#endif
 #endif /* CCAN_COMPILER_H */