Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
panic.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2015 Roc Streaming authors
3
*
4
* This Source Code Form is subject to the terms of the Mozilla Public
5
* License, v. 2.0. If a copy of the MPL was not distributed with this
6
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
7
*/
8
9
//! @file roc_core/panic.h
10
//! @brief Panic.
11
12
#ifndef ROC_CORE_PANIC_H_
13
#define ROC_CORE_PANIC_H_
14
15
#include "
roc_core/attributes.h
"
16
#include "
roc_core/macro_helpers.h
"
17
18
#ifndef ROC_MODULE
19
#error "ROC_MODULE not defined"
20
#endif
21
22
//! Panic if condition is true.
23
//! @note
24
//! This is a shorthand; roc_panic() with a meaningful error message is
25
//! preferred way to panic.
26
#define roc_panic_if(x) \
27
do { \
28
if ((x)) { \
29
roc_panic("%s"
, #x); \
30
} \
31
} while (0)
32
33
//! Panic if condition is false.
34
//! @note
35
//! This is a shorthand; roc_panic() with a meaningful error message is
36
//! preferred way to panic.
37
#define roc_panic_if_not(x) roc_panic_if(!(x))
38
39
//! Panic if condition is true, printing custom message.
40
#define roc_panic_if_msg(x, ...) \
41
do { \
42
if ((x)) { \
43
roc_panic(__VA_ARGS__); \
44
} \
45
} while (0)
46
47
//! Print error message and terminate program gracefully.
48
//! @remarks
49
//! Never returns and never throws.
50
#define roc_panic(...) \
51
::roc::core::panic(ROC_STRINGIZE(ROC_MODULE), __FILE__, __LINE__, __VA_ARGS__)
52
53
namespace
roc
{
54
namespace
core {
55
56
//! Print error message and terminate program gracefully.
57
ROC_ATTR_NORETURN
ROC_ATTR_PRINTF
(4, 5) void
panic
(
58
const
char
* module, const
char
* file,
int
line, const
char
* format, ...);
59
60
}
// namespace core
61
}
// namespace roc
62
63
#endif
// ROC_CORE_PANIC_H_
attributes.h
Compiler attributes.
ROC_ATTR_NORETURN
#define ROC_ATTR_NORETURN
Function never returns.
Definition:
attributes.h:24
ROC_ATTR_PRINTF
#define ROC_ATTR_PRINTF(fmt_pos, args_pos)
Function gets printf-like arguments.
Definition:
attributes.h:35
macro_helpers.h
Helper macros.
roc::core::panic
void panic(const char *module, const char *file, int line, const char *format,...)
Print error message and terminate program gracefully.
roc
Root namespace.
roc_core
panic.h
Generated by
1.9.1