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.


Define Documentation

#define NS_ASSERT ( condition   ) 

Value:

do                                                            \
    {                                                           \
      if (!(condition))                                         \
        {                                                       \
          std::cerr << "assert failed. file=" << __FILE__ <<    \
            ", line=" << __LINE__ << ", cond=\""#condition <<   \
            "\"" << std::endl;                                  \
          int *a = 0;                                           \
          *a = 0;                                               \
        }                                                       \
    }                                                           \
  while (false)
Parameters:
condition condition to verifiy.
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 dereferencing a null pointer.

Referenced by ns3::CopyObject(), ns3::TagBuffer::ReadU8(), ns3::Buffer::Buffer::Iterator::ReadU8(), ns3::Object::Unref(), ns3::TagBuffer::WriteU8(), and ns3::Buffer::Buffer::Iterator::WriteU8().

#define NS_ASSERT_MSG ( condition,
message   ) 

Value:

do                                            \
    {                                           \
      if (!(condition))                         \
        {                                       \
          std::cerr << message << std::endl;    \
          int *a = 0;                           \
          *a = 0;                               \
        }                                       \
    }                                           \
  while (false)
Parameters:
condition condition to verifiy.
message message to output
At runtime, in debugging builds, if this condition is not true, the program prints the message to output and halts by dereferencing a null pointer.

Referenced by ns3::rapidnet::AggWrap::New().


Generated on Fri Apr 9 15:00:52 2010 for NS-3 by  doxygen 1.5.8