BRL-CAD
assert.h
Go to the documentation of this file.
1
/* A S S E R T . H
2
* BRL-CAD
3
*
4
* Copyright (c) 2020-2023 United States Government as represented by
5
* the U.S. Army Research Laboratory.
6
*
7
* This library is free software; you can redistribute it and/or
8
* modify it under the terms of the GNU Lesser General Public License
9
* version 2.1 as published by the Free Software Foundation.
10
*
11
* This library is distributed in the hope that it will be useful, but
12
* WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
* Lesser General Public License for more details.
15
*
16
* You should have received a copy of the GNU Lesser General Public
17
* License along with this file; see the file named COPYING for more
18
* information.
19
*/
20
21
/** @addtogroup bu_defines */
22
/** @{ */
23
24
#ifndef BU_ASSERT_H
25
#define BU_ASSERT_H
26
27
#include "
common.h
"
28
29
#include "
bu/defines.h
"
30
#include "
bu/log.h
"
31
#include "
bu/exit.h
"
32
33
34
/**
35
* @def BU_ASSERT(expression)
36
* @brief Alternative for assert(3) that calls LIBBU logging+bombing.
37
*
38
* This is a simple macro wrapper that logs an assertion-failure error
39
* message and aborts application execution if the specified
40
* expression is not hold true. While it is similar in use, this
41
* wrapper does not utilize assert(3) or NDEBUG but is disabled if
42
* NO_BOMBING_MACROS is defined by the configuration.
43
*/
44
#ifdef NO_BOMBING_MACROS
45
# define BU_ASSERT(expression_) (void)(expression_)
46
#else
47
# define BU_ASSERT(expression_) \
48
if (UNLIKELY(!(expression_))) { \
49
const char *expression_buf_ = #expression_; \
50
bu_log("BU_ASSERT(%s) failure in file %s, line %d\n"
, \
51
expression_buf_, __FILE__, __LINE__); \
52
bu_bomb("BU_ASSERT FAILED\n"); \
53
}
54
#endif
55
56
/** @} */
57
58
#endif
/* BU_ASSERT_H */
59
60
/*
61
* Local Variables:
62
* mode: C
63
* tab-width: 8
64
* indent-tabs-mode: t
65
* c-file-style: "stroustrup"
66
* End:
67
* ex: shiftwidth=4 tabstop=8
68
*/
defines.h
common.h
Header file for the BRL-CAD common definitions.
exit.h
log.h
include
bu
assert.h
Generated on Tue Mar 7 2023 23:41:49 for BRL-CAD by
1.9.3