...
Code Block | ||
---|---|---|
| ||
#include <assert.h> void myassert(int e) { assert(e); /* other verification ... */ } |
Noncompliant Code Example (Redefining errno)
Legacy code is apt to include an incorrect declaration such as the following.
Code Block | ||
---|---|---|
| ||
extern int errno;
|
Compliant Solution (Redefining errno)
The correct way to declare errno
is to include the header <errno.h>
.
Code Block | ||
---|---|---|
| ||
#include <errno.h>
|
Implementations conforming to C99 are required to declare errno
in <errno.h>
, although some historic implementations failed to do so.
Risk Assessment
Accessing objects or function underlying these macros does not produce defined behavior, which may lead to incorrect or unexpected program behavior.
...