ref: b180a3feacde90c3e43e5b5b55300eea3317e328
parent: e3f6ad0b0cff1e17249d436c91b70479c5aba0c9
author: Gregory Maxwell <[email protected]>
date: Thu Sep 29 13:43:44 EDT 2011
Make silk_assert calls work with the autotools --enable-assertions.
--- a/silk/typedef.h
+++ b/silk/typedef.h
@@ -81,7 +81,19 @@
# define silk_assert(COND) _ASSERTE(COND)
# endif
#else
-# define silk_assert(COND)
+# ifdef ENABLE_ASSERTIONS
+# include <stdio.h>
+# include <stdlib.h>
+#define silk_fatal(str) _silk_fatal(str, __FILE__, __LINE__);
+static inline void _silk_fatal(const char *str, const char *file, int line)
+{
+ fprintf (stderr, "Fatal (internal) error in %s, line %d: %s\n", file, line, str);
+ abort();
+}
+# define silk_assert(COND) {if (!(COND)) {silk_fatal("assertion failed: " #COND);}}
+# else
+# define silk_assert(COND)
+# endif
#endif
#endif