ret = foo();
assert(ret == 0);
If that condition is false, the program will exit, print an error saying that this assertion was hit and generate a core dump (if the system is configured to). It can make life a bit easier if we add an error string to the same check:
ret = foo();
assert(ret == 0 || "foo() returned non-zero when called from bar()");
No comments:
Post a Comment