August 2011
Intermediate to advanced
552 pages
23h 48m
English
Assertions are a programming technique where tests are added for conditions that cannot happen. The program kills itself when it enters such an impossible state, dumping a core file if it can.
The assert macro
assert (expression)evaluates the expression. If the expression is zero (false), the process is terminated, a diagnostic message is written to the standard error stream, and the abort() function is called, which terminates the program by raising the signal SIGABRT. Because most programmers use asserts for debugging purposes, you can compile them out of a production program by using the preprocessor flag -DNDEBUG. Be aware of side effects due to code called in the assert() macro. This could cause your program ...
Read now
Unlock full access