Scroom
0.14
assertions.hh
Go to the documentation of this file.
1
/*
2
* Scroom - Generic viewer for 2D data
3
* Copyright (C) 2009-2022 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
(std::string_view type,
18
std::string_view expr,
19
std::string_view
function
,
20
std::string_view filename,
21
unsigned
int
line) __attribute__((noreturn));
22
}
// namespace Scroom::Utils::Detail
23
24
#ifdef _WIN32
25
# define __STRING(x) # x
26
#endif
27
28
#define require(expr) \
29
((expr) ? ((void)0) \
30
: Scroom::Utils::Detail::assertionFailed( \
31
"precondition", __STRING(expr), static_cast<const char*>(__PRETTY_FUNCTION__), __FILE__, __LINE__))
32
#define ensure(expr) \
33
((expr) ? ((void)0) \
34
: Scroom::Utils::Detail::assertionFailed( \
35
"postcondition", __STRING(expr), static_cast<const char*>(__PRETTY_FUNCTION__), __FILE__, __LINE__))
36
#define verify(expr) \
37
((expr) ? ((void)0) \
38
: Scroom::Utils::Detail::assertionFailed( \
39
"assertion", __STRING(expr), static_cast<const char*>(__PRETTY_FUNCTION__), __FILE__, __LINE__))
40
#define defect() \
41
Scroom::Utils::Detail::assertionFailed( \
42
"control flow assertion", "", static_cast<const char*>(__PRETTY_FUNCTION__), __FILE__, __LINE__)
43
#define defect_message(m) \
44
Scroom::Utils::Detail::assertionFailed( \
45
"control flow assertion", (m), static_cast<const char*>(__PRETTY_FUNCTION__), __FILE__, __LINE__)
Scroom::Utils::Detail
Definition:
assertions.hh:14
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:50
inc
scroom
assertions.hh
Generated by
1.8.17