chiark / gitweb /
anag.h: Mark `die' as non-returning and accepting a `printf' format.
[anag] / anag.h
diff --git a/anag.h b/anag.h
index f9eb5a36b54b1a42d4efce203f39fb7eaae6c860..0223c54ecc92b757131f8281b3ff4e40870d8524 100644 (file)
--- a/anag.h
+++ b/anag.h
@@ -1,13 +1,11 @@
 /* -*-c-*-
- *
- * $Id$
  *
  * External definitions for Anag
  *
  * (c) 2001 Mark Wooding
  */
 
-/*----- Licensing notice --------------------------------------------------* 
+/*----- Licensing notice --------------------------------------------------*
  *
  * This file is part of Anag: a simple wordgame helper.
  *
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation; either version 2 of the License, or
  * (at your option) any later version.
- * 
+ *
  * Anag is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
- * 
+ *
  * You should have received a copy of the GNU General Public License
  * along with Anag; if not, write to the Free Software Foundation,
  * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 #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 {
@@ -116,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 -------------------------------------------------*/