Loading...
Searching...
No Matches
symengine_assert.h
1#ifndef SYMENGINE_ASSERT_H
2#define SYMENGINE_ASSERT_H
3
4// SYMENGINE_ASSERT uses internal functions to perform as assert
5// so that there is no effect with NDEBUG
6#if defined(WITH_SYMENGINE_ASSERT)
7
8#if !defined(SYMENGINE_ASSERT)
9#define stringize(s) #s
10#define XSTR(s) stringize(s)
11#define SYMENGINE_ASSERT(cond) \
12 { \
13 if (!(cond)) { \
14 std::cerr << "SYMENGINE_ASSERT failed: " << __FILE__ \
15 << "\nfunction " << __func__ << "(), line number " \
16 << __LINE__ << " at \n" \
17 << XSTR(cond) << "\n"; \
18 abort(); \
19 } \
20 }
21#endif // !defined(SYMENGINE_ASSERT)
22
23#if !defined(SYMENGINE_ASSERT_MSG)
24#define SYMENGINE_ASSERT_MSG(cond, msg) \
25 { \
26 if (!(cond)) { \
27 std::cerr << "SYMENGINE_ASSERT failed: " << __FILE__ \
28 << "\nfunction " << __func__ << "(), line number " \
29 << __LINE__ << " at \n" \
30 << XSTR(cond) << "\n" \
31 << "ERROR MESSAGE:\n" \
32 << msg << "\n"; \
33 abort(); \
34 } \
35 }
36#endif // !defined(SYMENGINE_ASSERT_MSG)
37
38#else // defined(WITH_SYMENGINE_ASSERT)
39
40#define SYMENGINE_ASSERT(cond)
41#define SYMENGINE_ASSERT_MSG(cond, msg)
42
43#endif // defined(WITH_SYMENGINE_ASSERT)
44
45#define SYMENGINE_ERROR(description) \
46 std::cerr << description; \
47 std::cerr << "\n"; \
48 abort();
49
50#endif // SYMENGINE_ASSERT_H