O'Reilly logo

Advanced Mac OS X Programming: The Big Nerd Ranch Guide by Mark Dalrymple

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

For the More Curious: Assertions

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required