The line above shows the affect of a bug in a software system. The line represents the state of the system. The bug is activated at the point "bad" in the line. The earlier we catch the bug, the better the chances of avoiding an ill affect later. Assertions can help catch bugs early and leave the system in a more stable state. This enables us to debug a little better.
In "C" assertions are supported by including assert.h.
assert(condition), takes in one parameter. From the man page of assert
The macro assert() generates no code, and hence does nothing
at all. Otherwise, the macro assert() prints an error message to stan-
dard output and terminates the program by calling abort() if expression
is false (i.e., condition equal to zero).
The purpose of this macro is to help the programmer find bugs in his
program. The message "assertion failed in file
No comments:
Post a Comment