diff options
author | Campbell Barton <ideasman42@gmail.com> | 2010-12-15 13:22:26 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2010-12-15 13:22:26 +0300 |
commit | 35fa581403dc056528968234f608c4a7d68da26a (patch) | |
tree | 272e43d74a10b9ed9ddf43351c4407ad5d74e19e /source/blender/blenkernel | |
parent | eac46088e5a63991d2894197bbe14971864541ed (diff) |
BKE_assert(), only prints the error unless cmake define WITH_ASSERT_ABORT is enabled and it will call abort().
made this option advanced so people don't enable along with other features.
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/BKE_utildefines.h | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/source/blender/blenkernel/BKE_utildefines.h b/source/blender/blenkernel/BKE_utildefines.h index a1968459fd6..605a50e078b 100644 --- a/source/blender/blenkernel/BKE_utildefines.h +++ b/source/blender/blenkernel/BKE_utildefines.h @@ -54,6 +54,41 @@ # define UNUSED(x) UNUSED_ ## x #endif + +/* BKE_assert(), default only to print + * for aborting need to define WITH_ASSERT_ABORT */ +#if !defined NDEBUG +# ifdef WITH_ASSERT_ABORT +# define _dummy_abort abort +# else +# define _dummy_abort() (void)0 +# endif +# ifdef __GNUC__ /* just want to check if __func__ is available */ +# define BKE_assert(a) \ +do { \ + if (0 == (a)) { \ + fprintf(stderr, \ + "BKE_assert failed: %s, %s(), %d at \'%s\'\n", \ + __FILE__, __func__, __LINE__, STRINGIFY(a)); \ + _dummy_abort(); \ + } \ +} while (0) +# else +# define BKE_assert(a) \ +do { \ + if (0 == (a)) { \ + fprintf(stderr, \ + "BKE_assert failed: %s, %d at \'%s\'\n", \ + __FILE__, __LINE__, STRINGIFY(a)); \ + _dummy_abort(); \ + } \ +} while (0) +# endif +#else +# define BKE_assert(a) (void)0 +#endif + + /* these values need to be hardcoded in structs, dna does not recognize defines */ /* also defined in DNA_space_types.h */ #ifndef FILE_MAXDIR |