...
Suppose the custom <myassert.h>
declares a function assert()
that does nonstandard verification, and the standard <assert.h>
defines an assert
macro as required by the standard.:
Code Block | ||||
---|---|---|---|---|
| ||||
#include <myassert.h> #include <assert.h> void fullAssert(int e) { assert(0 < e); // Invoke standard library assert() (assert)(0 < e); // assert() macro suppressed, calling function assert() } |
...
The programmer should place nonstandard verification in a function that does not conflict with the standard library macro assert
—for example, myassert()
.:
Code Block | ||||
---|---|---|---|---|
| ||||
#include <myassert.h> #include <assert.h> void fullAssert(int e) { assert(0 < e); // Standard library assert() myassert(e); // Well-defined custom assertion function } |
...
Legacy code is apt to include an incorrect declaration, such as the following.:
Code Block | ||||
---|---|---|---|---|
| ||||
extern int errno; |
...
The correct way to declare errno
is to include the header <errno.h>
.:
Code Block | ||||
---|---|---|---|---|
| ||||
#include <errno.h> |
...