Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

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
bgColor#FFcccc
langc
#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
bgColor#ccccff
langc
#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
bgColor#FFcccc
langc
extern int errno;

...

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

Code Block
bgColor#ccccff
langc
#include <errno.h>

...