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
std::cerr << "aborted. "; \
42
NS_FATAL_ERROR(msg); \
43
} while (false)
44
45
/**
46
* \ingroup fatal
47
*
48
* \brief Abnormal program termination if a condition is \c true.
49
*
50
* \param [in] cond The condition to be evaluated.
51
*
52
* This is similar to \c NS_ASSERT(!(cond)), except this check
53
* is enabled in all builds. If \c cond is evaluated to \c true,
54
* the expression for \c cond is printed to \c stderr,
55
* followed by a call to the NS_FATAL_ERROR_NO_MSG() macro
56
* which prints the details of filename and line number to
57
* \c stderr. The program will be halted by calling
58
* \c std::terminate(), triggering any clean up code registered
59
* by \c std::set_terminate. The ns-3 default is a stream-flushing
60
* code, but may be overridden.
61
*
62
* This macro is enabled unconditionally in all builds,
63
* including debug and optimized builds.
64
*/
65
#define NS_ABORT_IF(cond) \
66
do \
67
{ \
68
if (cond) \
69
{ \
70
std::cerr << "aborted. cond=\"" << #cond << ", "; \
71
NS_FATAL_ERROR_NO_MSG(); \
72
} \
73
} while (false)
74
75
/**
76
* \ingroup fatal
77
*
78
* \brief Abnormal program termination if a condition is \c true,
79
* with a message.
80
*
81
* \param [in] cond The condition to be evaluated.
82
* \param [in] msg The message to output when cond is \c true.
83
*
84
* This is similar to NS_ASSERT_MSG(!(cond)), except this
85
* check is enabled in all builds. If \c cond is evaluated to
86
* \c true, the expression for \c cond is printed to
87
* \c stderr, followed by a call to the NS_FATAL_ERROR() macro
88
* which prints the user-specified error message, and details
89
* of filename and line number to \c stderr. The program will
90
* be halted by calling \c std::terminate(), triggering any
91
* clean up code registered by \c std::set_terminate. The ns-3
92
* default is a stream-flushing code, but may be overridden.
93
*
94
* This macro is enabled unconditionally in all builds,
95
* including debug and optimized builds.
96
*/
97
#define NS_ABORT_MSG_IF(cond, msg) \
98
do \
99
{ \
100
if (cond) \
101
{ \
102
std::cerr << "aborted. cond=\"" << #cond << "\", "; \
103
NS_FATAL_ERROR(msg); \
104
} \
105
} while (false)
106
107
/**
108
* \ingroup fatal
109
*
110
* \brief Abnormal program termination if a condition is \c false.
111
*
112
* \param [in] cond The condition to be evaluated.
113
*
114
* This is an alias for NS_ABORT_IF(!(cond))
115
*
116
* \see NS_ABORT_IF
117
*/
118
#define NS_ABORT_UNLESS(cond) NS_ABORT_IF(!(cond))
119
120
/**
121
* \ingroup fatal
122
*
123
* \brief Abnormal program termination if a condition is \c false,
124
* with a message.
125
*
126
* \param [in] cond The condition to be evaluated.
127
* \param [in] msg The message to output if cond is false.
128
*
129
* This is an alias for NS_ABORT_MSG_IF(!(cond))
130
*
131
* \see NS_ABORT_MSG_IF
132
*/
133
#define NS_ABORT_MSG_UNLESS(cond, msg) NS_ABORT_MSG_IF(!(cond), msg)
134
135
#endif
/* NS3_ABORT_H */
fatal-error.h
NS_FATAL_x macro definitions.
src
core
model
abort.h
Generated on Fri Nov 8 2024 13:58:59 for ns-3 by
1.11.0