Scroom
0.14-49-gb7ae7a6d
Loading...
Searching...
No Matches
assertions.hh
Go to the documentation of this file.
1
/*
2
* Scroom - Generic viewer for 2D data
3
* Copyright (C) 2009-2026 Kees-Jan Dijkzeul
4
*
5
* SPDX-License-Identifier: LGPL-2.1
6
*/
7
8
#pragma once
9
10
#include <string_view>
11
12
#include <sys/cdefs.h>
13
14
namespace
Scroom::Utils::Detail
15
{
17
[[noreturn]]
void
assertionFailed
(
18
std::string_view type,
19
std::string_view expr,
20
std::string_view function,
21
std::string_view filename,
22
unsigned
int
line
23
) __attribute__((noreturn));
24
}
// namespace Scroom::Utils::Detail
25
26
#ifdef _WIN32
27
# define __STRING(x) #x
28
#endif
29
30
#define require(expr) \
31
((expr) ? ((void)0) \
32
: Scroom::Utils::Detail::assertionFailed( \
33
"precondition", __STRING(expr), static_cast<const char*>(__PRETTY_FUNCTION__), __FILE__, __LINE__ \
34
))
35
#define ensure(expr) \
36
((expr) ? ((void)0) \
37
: Scroom::Utils::Detail::assertionFailed( \
38
"postcondition", __STRING(expr), static_cast<const char*>(__PRETTY_FUNCTION__), __FILE__, __LINE__ \
39
))
40
#define verify(expr) \
41
((expr) ? ((void)0) \
42
: Scroom::Utils::Detail::assertionFailed( \
43
"assertion", __STRING(expr), static_cast<const char*>(__PRETTY_FUNCTION__), __FILE__, __LINE__ \
44
))
45
#define defect() \
46
Scroom::Utils::Detail::assertionFailed( \
47
"control flow assertion", "", static_cast<const char*>(__PRETTY_FUNCTION__), __FILE__, __LINE__ \
48
)
49
#define defect_message(m) \
50
Scroom::Utils::Detail::assertionFailed( \
51
"control flow assertion", (m), static_cast<const char*>(__PRETTY_FUNCTION__), __FILE__, __LINE__ \
52
)
Scroom::Utils::Detail
Definition
assertions.hh:15
Scroom::Utils::Detail::assertionFailed
void assertionFailed(std::string_view type, std::string_view expr, std::string_view function, std::string_view filename, unsigned int line) __attribute__((noreturn))
Definition
assertions.cc:51
libs
util
inc
scroom
assertions.hh
Generated by
1.9.8