Euphoria
Main Page
Related Pages
Topics
Namespaces
Classes
Files
File List
File Members
libs
assert
src
assert
assert.h
Go to the documentation of this file.
1
#pragma once
2
3
#include <string>
4
#include <vector>
5
6
#include "fmt/format.h"
7
10
#define BREAK_IN_DEBUG() \
11
do \
12
{ \
13
} while(false)
14
15
16
#ifdef RELEASE
17
18
// todo(Gustav): implement assert for windows...
19
20
#define ASSERT(x)
21
#define ASSERTX(x, ...)
22
#define DIE(message)
23
24
#else
25
26
#if !defined(__PRETTY_FUNCTION__) && !defined(__GNUC__)
27
#define __PRETTY_FUNCTION__ __FUNCSIG__
28
#endif
29
32
#define IMPLEMENT_ASSERT_LIB
33
34
// todo(Gustav): stb libraries and rapidjson aren't using our assert
38
#define ASSERT(x) \
39
do \
40
{ \
41
if(x) \
42
{ \
43
} \
44
else \
45
{ \
46
if(::eu::assertlib::is_throwing() == false) { BREAK_IN_DEBUG(); } \
47
::eu::assertlib::on_assert( \
48
#x, \
49
__LINE__, \
50
__FILE__, \
51
"", \
52
{}, \
53
__PRETTY_FUNCTION__); \
54
} \
55
} while(false)
56
61
#define ASSERTX(x, ...) \
62
do \
63
{ \
64
if(x) \
65
{ \
66
} \
67
else \
68
{ \
69
if(::eu::assertlib::is_throwing() == false) { BREAK_IN_DEBUG(); } \
70
::eu::assertlib::on_assert( \
71
#x, \
72
__LINE__, \
73
__FILE__, \
74
#__VA_ARGS__, \
75
{__VA_ARGS__}, \
76
__PRETTY_FUNCTION__); \
77
} \
78
} while(false)
79
83
#define DIE(message) \
84
::eu::assertlib::on_assert( \
85
message, \
86
__LINE__, \
87
__FILE__, \
88
"", \
89
{}, \
90
__PRETTY_FUNCTION__)
91
96
#define DIEX(message, ...) \
97
::eu::assertlib::on_assert( \
98
message, \
99
__LINE__, \
100
__FILE__, \
101
#__VA_ARGS__, \
102
{__VA_ARGS__}, \
103
__PRETTY_FUNCTION__)
104
105
#endif
// _MSC_VER
106
107
#ifdef IMPLEMENT_ASSERT_LIB
108
110
namespace
eu::assertlib
111
{
113
struct
AssertArgumentValue
114
{
115
std::string value;
116
117
template
<
typename
T>
118
AssertArgumentValue(
const
T& t)
119
: value(fmt::to_string(t))
120
{}
121
};
122
124
void
125
begin_throwing();
126
128
bool
129
is_throwing();
130
132
void
133
on_assert
134
(
135
const
char
* expression,
136
int
line,
137
const
char
* file,
138
const
char
* argstr,
139
const
std::vector<AssertArgumentValue>& arguments,
140
const
char
* function
141
);
142
}
143
#endif
// IMPLEMENT_ASSERT_LIB
144
eu::assertlib
Definition
assert.h:111
Generated by
1.9.8