Versions Compared


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


In this noncompliant code example, because the C standard library header <inttypes.h> is specified to include <stdint.h>, the name SIZE_MAX_SIZE conflicts with a standard macro of the same name, 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 the C Standard, 7.31.10).

Code Block
#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_SIZE = 80 };
  char buf[SIZE_MAX_SIZE];
  if (INTFAST16_LIMIT_MAX < val) {
    sprintf(buf, "The value is too large");
  } else {
    snprintf(buf, SIZE_MAX_SIZE, "The value is %" PRIdFAST16, val);