Skip to main content

IAR Embedded Workbench for RH850 3.20.x

CERT-DCL37-C_a

In this section:
Synopsis

Do not declare or define a reserved identifier

Enabled by default

Yes

Severity/Certainty

Low/Low

lowlow.png
Full description

Do not define a function with a reserved identifier This check is identical to MISRAC++2008-17-0-3, MISRAC2012-Rule-21.2, MISRAC2004-20.2.

Coding standards
CERT DCL37-C

Do not declare or define a reserved identifier

MISRA C:2004 20.2

(Required) The names of Standard Library macros, objects, and functions shall not be reused.

MISRA C:2012 Rule-21.2

(Required) A reserved identifier or macro name shall not be declared

MISRA C++ 2008 17-0-3

(Required) The names of standard library functions shall not be overridden.

Code examples

The following code example fails the check and will give a warning:

#include <stddef.h>

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

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

The following code example passes the check and will not give a warning about this issue:

#include <stddef.h>

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

void *my_aligned_alloc(size_t alignment, size_t size) {
  void *ptr;
  /* Allocate storage from own pool, align properly, set ptr */
  return ptr;
}

void *my_calloc(size_t nelems, size_t elsize) {
  void *ptr;
  /* Allocate storage from own pool, zero memory, and set ptr */
  return ptr;
}

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

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