]> git.ozlabs.org Git - ccan/blobdiff - ccan/compiler/compiler.h
compiler: fix -Wwrite-strings warning in example.
[ccan] / ccan / compiler / compiler.h
index d57d814b3711213c978602cd46c7c6e2e67ccf7d..aa7323f5ff9cbc6805620e7aa4bce0383276508d 100644 (file)
 #define COLD
 #endif
 
+#if HAVE_ATTRIBUTE_NORETURN
+/**
+ * NORETURN - a function does not return
+ *
+ * Used to mark a function which exits; useful for suppressing warnings.
+ *
+ * Example:
+ * static void NORETURN fail(const char *reason)
+ * {
+ *     fprintf(stderr, "Error: %s (%s)\n", reason, strerror(errno));
+ *     exit(1);
+ * }
+ */
+#define NORETURN __attribute__((noreturn))
+#else
+#define NORETURN
+#endif
+
 #if HAVE_ATTRIBUTE_PRINTF
 /**
  * PRINTF_FMT - a function takes printf-style arguments
  *     const char *greek_name(enum greek greek);
  *
  *     // Inline version.
- *     static inline char *_greek_name(enum greek greek)
+ *     static inline const char *_greek_name(enum greek greek)
  *     {
  *             switch (greek) {
  *             case ALPHA: return "alpha";