Versions Compared

Key

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

...

Code Block
bgColor#FFCCCC
langcpp

#ifndef _MY_HEADER_H_
#define _MY_HEADER_H_

// contents of <my_header.h>

#endif // _MY_HEADER_H_

...

Code Block
bgColor#ccccff
langcpp

#ifndef MY_HEADER_H
#define MY_HEADER_H

// contents of <my_header.h>

#endif // MY_HEADER_H

...

Code Block
bgColor#FFCCCC
langcpp

#include <cstddef>   // for size_t

static const std::size_t _max_limit = 1024;
std::size_t _limit = 100;

unsigned int getValue(unsigned int count) {
  return count < _limit ? count : _limit;
}

...

Code Block
bgColor#ccccff
langcpp

#include <cstddef>   // for size_t

static const std::size_t max_limit = 1024;
std::size_t limit = 100;

unsigned int getValue(unsigned int count) {
  return count < limit ? count : limit;
}

...

Code Block
bgColor#ffcccc
langcpp

#include <inttypes.h>   // for int_fast16_t and PRIdFAST16

static const int_fast16_t INTFAST16_LIMIT_MAX = 12000;

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

...

Code Block
bgColor#ccccff
langcpp

#include <inttypes.h>   // for int_fast16_t and PRIdFAST16

static const int_fast16_t MY_INTFAST16_UPPER_LIMIT = 12000;

void print_fast16(int_fast16_t val) {
    enum { BUFSIZE = 80 };
    char buf [BUFSIZE];
    if (MY_INTFAST16_UPPER_LIMIT < val)
      std::sprintf(buf, "The value is too large");
    else
      std::snprintf(buf, BUFSIZE, "The value is %" PRIdFAST16, val);
    // ...
}

...

Code Block
bgColor#ffcccc
langcpp

#include <cstddef>

void* malloc(std::size_t nbytes) {
  void *ptr;
  // allocate storage from own pool and set ptr
  return ptr;
}

void free(void *ptr) {
  // return storage to own pool
}

...

Code Block
bgColor#ccccff
langcpp

#include <cstddef>

void* my_malloc(std::size_t nbytes) {
  void *ptr;
  // allocate storage from own pool and set ptr
  return ptr;
}

void* my_calloc(std::size_t nelems, std::size_t elsize) {
  void *ptr;
  /// allocate storage from own pool and set ptr
  return ptr;
}

void* my_realloc(void *ptr, std::size_t nbytes) {
  // reallocate storage from own pool and set ptr
  return ptr;
}

void my_free(void *ptr) {
  // return storage to own pool
}

...

DCL31-CPP. Do not define variadic functions      02002. Declarations and Initialization (DCL)      DCL33-CPP. Never qualify a variable of reference type with const or volatile