diff options
author | Lennart Poettering <lennart@poettering.net> | 2007-04-25 10:27:13 +0000 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2007-04-25 10:27:13 +0000 |
commit | 2eb6dec8e9f0114bdbad59cf8f11f197f8fdaaf3 (patch) | |
tree | 88a2b13b2fc9abdd9fa43136d4ed91bdc084d929 /macro.h | |
parent | 130f9f7046eec89f7674cad7f66c831fa8d0127d (diff) |
initial commit
git-svn-id: file:///home/lennart/svn/public/libsydney/trunk@3 9ba3c220-e4d3-45a2-8aa3-73fcc9aff6ce
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 |