Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacques Lucke <jacques@blender.org>2021-03-23 18:45:44 +0300
committerJacques Lucke <jacques@blender.org>2021-03-23 18:45:44 +0300
commit433fb9326ece7b0b84f2f548e43059881cca68b5 (patch)
treefdfaf85e5e41b2f2c7d1182b68fc985dc436a221 /source/blender/blenlib/intern/BLI_assert.c
parent7046e37eded55ac8879835500788a1e734437bbf (diff)
BLI: add macro to indicate unreachable code
This adds a `BLI_assert_unreachable()` macro, that should be used instead of `BLI_assert(false)` in many places. * `BLI_assert_unreachable` provides more information than `BLI_assert(false)` to people reading the code. * `BLI_assert_unreachable` will print an error to `stderr` in a release build. This makes it more likely that we will get bug reports when the assumptions of a developer were wrong. Differential Revision: https://developer.blender.org/D10780
Diffstat (limited to 'source/blender/blenlib/intern/BLI_assert.c')
-rw-r--r--source/blender/blenlib/intern/BLI_assert.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/source/blender/blenlib/intern/BLI_assert.c b/source/blender/blenlib/intern/BLI_assert.c
index f397cdcd8a9..887f583242f 100644
--- a/source/blender/blenlib/intern/BLI_assert.c
+++ b/source/blender/blenlib/intern/BLI_assert.c
@@ -31,6 +31,12 @@ void _BLI_assert_print_pos(const char *file, const int line, const char *functio
fprintf(stderr, "BLI_assert failed: %s:%d, %s(), at \'%s\'\n", file, line, function, id);
}
+void _BLI_assert_unreachable_print(const char *file, const int line, const char *function)
+{
+ fprintf(stderr, "Code marked as unreachable has been executed. Please report this as a bug.\n");
+ fprintf(stderr, "Error found at %s:%d in %s.\n", file, line, function);
+}
+
void _BLI_assert_print_backtrace(void)
{
#ifndef NDEBUG