assert functions and macros
More...
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.
#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.