A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
Loading...
Searching...
No Matches
abort.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2008 INRIA, 2010 NICTA
3
*
4
* SPDX-License-Identifier: GPL-2.0-only
5
*
6
* Author: Original author unknown
7
* Quincy Tse <quincy.tse@nicta.com.au>
8
*/
9
#ifndef NS3_ABORT_H
10
#define NS3_ABORT_H
11
12
#include "
fatal-error.h
"
13
14
/**
15
* @file
16
* @ingroup fatal
17
* @brief \c NS_ABORT_x macro definitions.
18
*/
19
20
/**
21
* @ingroup fatal
22
*
23
* @brief Unconditional abnormal program termination with a message.
24
*
25
* @param [in] msg The message to output when this macro is hit.
26
*
27
* This macro is essentially equivalent to NS_FATAL_ERROR,
28
* except it prepends the error message with the string
29
* "aborted. ". When this macro is hit at runtime, the
30
* program will be halted using \c std::terminate, which
31
* triggers clean up code registered by \c std::set_terminate.
32
*
33
* This macro is enabled unconditionally in all builds,
34
* including debug and optimized builds.
35
*
36
* @see NS_FATAL_ERROR
37
*/
38
#define NS_ABORT_MSG(msg) \
39
do \
40
{ \
41
::ns3::LogLineFlushPartial(); \
42
std::cerr << "aborted. "; \
43
NS_FATAL_ERROR(msg); \
44
} while (false)
45
46
/**
47
* @ingroup fatal
48
*
49
* @brief Abnormal program termination if a condition is \c true.
50
*
51
* @param [in] cond The condition to be evaluated.
52
*
53
* This is similar to \c NS_ASSERT(!(cond)), except this check
54
* is enabled in all builds. If \c cond is evaluated to \c true,
55
* the expression for \c cond is printed to \c stderr,
56
* followed by a call to the NS_FATAL_ERROR_NO_MSG() macro
57
* which prints the details of filename and line number to
58
* \c stderr. The program will be halted by calling
59
* \c std::terminate(), triggering any clean up code registered
60
* by \c std::set_terminate. The ns-3 default is a stream-flushing
61
* code, but may be overridden.
62
*
63
* This macro is enabled unconditionally in all builds,
64
* including debug and optimized builds.
65
*/
66
#define NS_ABORT_IF(cond) \
67
do \
68
{ \
69
if (cond) \
70
{ \
71
::ns3::LogLineFlushPartial(); \
72
std::cerr << "aborted. cond=\"" << #cond << ", "; \
73
NS_FATAL_ERROR_NO_MSG(); \
74
} \
75
} while (false)
76
77
/**
78
* @ingroup fatal
79
*
80
* @brief Abnormal program termination if a condition is \c true,
81
* with a message.
82
*
83
* @param [in] cond The condition to be evaluated.
84
* @param [in] msg The message to output when cond is \c true.
85
*
86
* This is similar to NS_ASSERT_MSG(!(cond)), except this
87
* check is enabled in all builds. If \c cond is evaluated to
88
* \c true, the expression for \c cond is printed to
89
* \c stderr, followed by a call to the NS_FATAL_ERROR() macro
90
* which prints the user-specified error message, and details
91
* of filename and line number to \c stderr. The program will
92
* be halted by calling \c std::terminate(), triggering any
93
* clean up code registered by \c std::set_terminate. The ns-3
94
* default is a stream-flushing code, but may be overridden.
95
*
96
* This macro is enabled unconditionally in all builds,
97
* including debug and optimized builds.
98
*/
99
#define NS_ABORT_MSG_IF(cond, msg) \
100
do \
101
{ \
102
if (cond) \
103
{ \
104
::ns3::LogLineFlushPartial(); \
105
std::cerr << "aborted. cond=\"" << #cond << "\", "; \
106
NS_FATAL_ERROR(msg); \
107
} \
108
} while (false)
109
110
/**
111
* @ingroup fatal
112
*
113
* @brief Abnormal program termination if a condition is \c false.
114
*
115
* @param [in] cond The condition to be evaluated.
116
*
117
* This is an alias for NS_ABORT_IF(!(cond))
118
*
119
* @see NS_ABORT_IF
120
*/
121
#define NS_ABORT_UNLESS(cond) NS_ABORT_IF(!(cond))
122
123
/**
124
* @ingroup fatal
125
*
126
* @brief Abnormal program termination if a condition is \c false,
127
* with a message.
128
*
129
* @param [in] cond The condition to be evaluated.
130
* @param [in] msg The message to output if cond is false.
131
*
132
* This is an alias for NS_ABORT_MSG_IF(!(cond))
133
*
134
* @see NS_ABORT_MSG_IF
135
*/
136
#define NS_ABORT_MSG_UNLESS(cond, msg) NS_ABORT_MSG_IF(!(cond), msg)
137
138
#endif
/* NS3_ABORT_H */
fatal-error.h
NS_FATAL_x macro definitions.
src
core
model
abort.h
Generated on
for ns-3 by
1.16.1