Expert programmers use the assert() macro to seed their code with debugging statements. So should we all.
The macro must have no effect on the system – it shouldn’t change memory, interrupt state, or I/O, and it should make no function calls. The user must feel free to sprinkle these at will throughout the program. Disabling the asserts in released code must never change the way the program operates.
The macro generally looks something like:
#define
assert(s)
if (s)
{}else (printf("Error at %s %d: ", __FILE__, __LINE__)
It’s sort of an odd way to write code – if the condition is true (in which case assert() takes no action) there’s a null pair of braces. Why not test the negation of the statement “s”?




Typedef
