Assert functions and macros.
More...
|
#define | NS_ASSERT(condition) |
| At runtime, in debugging builds, if this condition is not true, the program prints the source file, line number and unverified condition and halts by calling std::terminate.
|
|
#define | NS_ASSERT_MSG(condition, message) |
| At runtime, in debugging builds, if this condition is not true, the program prints the message to output and halts by calling std::terminate.
|
|
|
These have to be visible for doxygen to document them, so we put them here in a file only seen by doxygen, not the compiler.
|
#define | NS3_ASSERT_ENABLE |
| Enable asserts at compile time.
|
|
#define | NS3_LOG_ENABLE |
| Enable logging at compile time.
|
|
Assert functions and macros.
The assert macros are used to verify at runtime that a certain condition is true. If it is not true, the program halts. These checks are built into the program only in debugging builds. They are removed in optimized builds.
These macro are intended to check certain conditions to be true. Do not put code that also have side effects that your program relies on (eg. code that advances an iterator and return false at end of file) because the code will not be executed on release builds!!
If assertion-style checks are required for release builds, use NS_ABORT_UNLESS and NS_ABORT_MSG_UNLESS.
◆ NS3_ASSERT_ENABLE
#define NS3_ASSERT_ENABLE |
Enable asserts at compile time.
This is normally set by ./ns3 configure --build-profile=debug
.
Definition at line 98 of file main.h.
◆ NS3_LOG_ENABLE
Enable logging at compile time.
This is normally set by ./ns3 configure --build-profile=debug
.
Definition at line 109 of file main.h.
◆ NS_ASSERT
#define NS_ASSERT |
( |
|
condition | ) |
|
Value: do \
{ \
if (!(condition)) \
{ \
std::cerr << "NS_ASSERT failed, cond=\"" << #condition << "\", "; \
NS_FATAL_ERROR_NO_MSG(); \
} \
} while (false)
At runtime, in debugging builds, if this condition is not true, the program prints the source file, line number and unverified condition and halts by calling std::terminate.
- Parameters
-
[in] | condition | Condition to verify. |
Definition at line 66 of file assert.h.
◆ NS_ASSERT_MSG
#define NS_ASSERT_MSG |
( |
|
condition, |
|
|
|
message |
|
) |
| |
Value: do \
{ \
if (!(condition)) \
{ \
std::cerr << "NS_ASSERT failed, cond=\"" << #condition << "\", "; \
NS_FATAL_ERROR(message); \
} \
} while (false)
At runtime, in debugging builds, if this condition is not true, the program prints the message to output and halts by calling std::terminate.
- Parameters
-
[in] | condition | Condition to verify. |
[in] | message | Message to output |
Definition at line 86 of file assert.h.