Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: minor editorial changes

...

Noncompliant Code Example (Header Guard)

...

In this noncompliant code example, because the C standard library header <inttypes.h> is specified to include <stdint.h>, the name SIZE_MAX conflicts with a standard macro of the same name, which is used to denote the upper limit of size_t. In addition, although the name INTFAST16_LIMIT_MAX is not defined by the C standard library, it is a reserved identifier because it begins with the INT prefix and ends with the _MAX suffix. (see See the C Standard, 7.31.10.).

Code Block
bgColor#ffcccc
langc
#include <inttypes.h>
#include <stdio.h>

static const int_fast16_t INTFAST16_LIMIT_MAX = 12000;

void print_fast16(int_fast16_t val) {
  enum { SIZE_MAX = 80 };
  char buf[SIZE_MAX];
  if (INTFAST16_LIMIT_MAX < val) {
    sprintf(buf, "The value is too large");
  } else {
    snprintf(buf, SIZE_MAX, "The value is %" PRIdFAST16, val);
  }
}

...

According to the C Standard, 7.5, paragraph 2 [ISO/IEC 9899:2011], the behavior of a program is undefined when

a macro A macro definition of errno is suppressed in order to access an actual object, or the program defines an identifier with the name errno

...