anag.h: Mark `die' as non-returning and accepting a `printf' format.
authorMark Wooding <mdw@distorted.org.uk>
Fri, 9 Aug 2019 11:01:02 +0000 (12:01 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Fri, 9 Aug 2019 11:02:52 +0000 (12:02 +0100)
anag.h

diff --git a/anag.h b/anag.h
index e16a3ae..0223c54 100644 (file)
--- a/anag.h
+++ b/anag.h
 #include <stdlib.h>
 #include <string.h>
 
+/*----- Preliminaries -----------------------------------------------------*/
+
+#if defined(__GNUC__)
+#  define GCC_VERSION_P(maj, min)                                       \
+       (__GNUC__ > (maj) || (__GNUC__ == (maj) && __GNUC_MINOR__ >= (min)))
+#else
+#  define GCC_VERSION_P(maj, min) 0
+#endif
+
+#ifdef __clang__
+#  define CLANG_VERSION_P(maj, min)                                     \
+       (__clang_major__ > (maj) || (__clang_major__ == (maj) &&        \
+                                    __clang_minor__ >= (min)))
+#else
+#  define CLANG_VERSION_P(maj, min) 0
+#endif
+
+#if GCC_VERSION_P(2, 5) || CLANG_VERSION_P(3, 3)
+#  define NORETURN __attribute__((noreturn))
+#  define PRINTF_LIKE(fix, aix) __attribute__((format(printf, fix, aix)))
+#endif
+
+#ifndef NORETURN
+#  define NORETURN
+#endif
+
+#ifndef PRINTF_LIKE
+#  define PRINTF_LIKE
+#endif
+
 /*----- Data structures ---------------------------------------------------*/
 
 typedef struct node {
@@ -114,7 +144,7 @@ extern int pquis(FILE */*fp*/, const char */*p*/);
  * Use:                Reports an error and exits.
  */
 
-extern void die(const char */*f*/, ...);
+extern PRINTF_LIKE(1, 2) NORETURN void die(const char */*f*/, ...);
 
 /*----- Memory allocation -------------------------------------------------*/