Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Moved in errno NCCE from DCL37-C (orig from ERR)

...

Code Block
bgColor#ccccff
#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
bgColor#FFcccc

extern int errno;

Compliant Solution (Redefining errno)

The correct way to declare errno is to include the header <errno.h>.

Code Block
bgColor#ccccff

#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.

...