August 2012
Intermediate to advanced
976 pages
30h 17m
English
C++ programmers sometimes use a technique similar to header guards (§ 2.6.3, p. 77) to conditionally execute debugging code. The idea is that the program will contain debugging code that is executed only while the program is being developed. When the application is completed and ready to ship, the debugging code is turned off. This approach uses two preprocessor facilities: assert and NDEBUG.
assert Preprocessor Macroassert
is a preprocessor macro. A preprocessor macro is a preprocessor variable that acts somewhat like an inline function. The assert macro takes a single expression, which it uses as a condition:
assert(expr);
evaluates expr and if the expression is false (i.e., zero), then assert writes a message ...
Read now
Unlock full access