From ef209a0427e586d84d01420aaa75487b0660e41a Mon Sep 17 00:00:00 2001 Message-Id: From: Mark Wooding Date: Fri, 9 Aug 2019 12:01:02 +0100 Subject: [PATCH] anag.h: Mark `die' as non-returning and accepting a `printf' format. Organization: Straylight/Edgeware From: Mark Wooding --- anag.h | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/anag.h b/anag.h index e16a3ae..0223c54 100644 --- a/anag.h +++ b/anag.h @@ -44,6 +44,36 @@ #include #include +/*----- 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 -------------------------------------------------*/ -- [mdw]