diff options
Diffstat (limited to 'macro.h')
-rw-r--r-- | macro.h | 33 |
1 files changed, 33 insertions, 0 deletions
@@ -0,0 +1,33 @@ +#ifndef foomacrohfoo +#define foomacrohfoo + +#include <stdio.h> +#include <assert.h> + +#ifdef __GNUC__ +#define PRETTY_FUNCTION __PRETTY_FUNCTION__ +#else +#define PRETTY_FUNCTION "" +#endif + +#define sa_return_if_fail(expr) \ + do { \ + if (!(expr)) { \ + fprintf(stderr, PRETTY_FUNCTION ": Assertion <" #expr "> failed.\n"); \ + return; \ + } \ + } while(0) + +#define sa_return_val_if_fail(expr, val) \ + do { \ + if (!(expr)) { \ + fprintf(stderr, "%s: Assertion <" #expr "> failed.\n", PRETTY_FUNCTION ); \ + return (val); \ + } \ + } while(0) + +#define sa_assert assert + +#define sa_assert_not_reached() sa_assert(!"Should not be reached.") + +#endif |