Blender V4.3
BLI_assert.c
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
11#include "BLI_assert.h" /* Own include. */
12
13#ifndef NDEBUG
14# include "BLI_system.h"
15#endif
16
17#include <stdio.h>
18#include <stdlib.h>
19
20void _BLI_assert_print_pos(const char *file, const int line, const char *function, const char *id)
21{
22 fprintf(stderr, "BLI_assert failed: %s:%d, %s(), at \'%s\'\n", file, line, function, id);
23}
24
26{
27 fprintf(stderr, " %s\n", str);
28}
29
30void _BLI_assert_unreachable_print(const char *file, const int line, const char *function)
31{
32 fprintf(stderr, "Code marked as unreachable has been executed. Please report this as a bug.\n");
33 fprintf(stderr, "Error found at %s:%d in %s.\n", file, line, function);
34}
35
37{
38#ifndef NDEBUG
40#endif
41}
42
44{
45 /* Wrap to remove 'noreturn' attribute since this suppresses missing return statements,
46 * allowing changes to debug builds to accidentally to break release builds.
47 *
48 * For example `BLI_assert_unreachable();` at the end of a function that returns a value,
49 * will hide that it's missing a return. */
50
51 abort();
52}
void _BLI_assert_print_backtrace(void)
Definition BLI_assert.c:36
void _BLI_assert_print_extra(const char *str)
Definition BLI_assert.c:25
void _BLI_assert_unreachable_print(const char *file, const int line, const char *function)
Definition BLI_assert.c:30
void _BLI_assert_print_pos(const char *file, const int line, const char *function, const char *id)
Definition BLI_assert.c:20
void _BLI_assert_abort(void)
Definition BLI_assert.c:43
void BLI_system_backtrace(FILE *fp)
Definition system.c:63
#define str(s)