A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
assert.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2006 INRIA, 2010 NICTA
3
*
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License version 2 as
6
* published by the Free Software Foundation;
7
*
8
* This program is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU General Public License for more details.
12
*
13
* You should have received a copy of the GNU General Public License
14
* along with this program; if not, write to the Free Software
15
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16
*
17
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
18
* Quincy Tse <quincy.tse@nicta.com.au>
19
*/
20
#ifndef NS_ASSERT_H
21
#define NS_ASSERT_H
22
51
#ifdef NS3_ASSERT_ENABLE
52
53
#include "
fatal-error.h
"
54
55
#include <iostream>
56
66
#define NS_ASSERT(condition) \
67
do \
68
{ \
69
if (!(condition)) \
70
{ \
71
std::cerr << "NS_ASSERT failed, cond=\""
<< #condition << "\", "; \
72
NS_FATAL_ERROR_NO_MSG(); \
73
} \
74
} while (false)
75
86
#define NS_ASSERT_MSG(condition, message) \
87
do \
88
{ \
89
if (!(condition)) \
90
{ \
91
std::cerr << "NS_ASSERT failed, cond=\""
<< #condition << "\", "; \
92
NS_FATAL_ERROR(message); \
93
} \
94
} while (false)
95
96
#else
/* NS3_ASSERT_ENABLE */
97
98
// NOTE: The no-op macros are not inserted into the final code.
99
// However, the use of sizeof() allows the compiler to silently check if the condition is
100
// syntactically valid.
101
102
#define NS_ASSERT(condition) \
103
do \
104
{ \
105
(void)sizeof(condition); \
106
} while (false)
107
108
#define NS_ASSERT_MSG(condition, message) \
109
do \
110
{ \
111
(void)sizeof(condition); \
112
} while (false)
113
114
#endif
/* NS3_ASSERT_ENABLE */
115
116
#endif
/* ASSERT_H */
fatal-error.h
NS_FATAL_x macro definitions.
src
core
model
assert.h
Generated on Sun Mar 3 2024 17:10:55 for ns-3 by
1.9.1