Assert
[Debugging]

assert functions and macros More...

Collaboration diagram for Assert:

Defines

#define NS_ASSERT(condition)
#define NS_ASSERT_MSG(condition, message)

Detailed Description

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.


Define Documentation

#define NS_ASSERT ( condition   ) 
Value:
do                                                            \
    {                                                           \
      if (!(condition))                                         \
        {                                                       \
          std::cerr << "assert failed. cond=\"" <<              \
            #condition << "\", ";                               \
          NS_FATAL_ERROR_NO_MSG();                              \
        }                                                       \
    }                                                           \
  while (false)
Parameters:
condition condition to verify.

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

Referenced by ns3::Buffer::Begin(), ns3::CopyObject(), ns3::Buffer::End(), ns3::Buffer::Iterator::Next(), ns3::Buffer::Iterator::Prev(), ns3::TagBuffer::ReadU8(), and ns3::TagBuffer::WriteU8().

#define NS_ASSERT_MSG ( condition,
message   ) 

Generated on 6 Jan 2011 for NS-3 by  doxygen 1.6.1