Skip to main content

IAR Embedded Workbench for Arm 9.70.x

MISRAC2012-Rule-21.10

In this section:
Synopsis

(Required) The Standard Library time and date functions shall not be used

Enabled by default

Yes

Severity/Certainty

Low/Medium

lowmedium.png
Full description

Use of the following wcsftime and time.h functions was found: asctime, clock, ctime, difftime, gmtime, localtime, mktime, strftime and time. This check is identical to MISRAC2004-20.12, MISRAC++2008-18-0-4.

Coding standards
MISRA C:2004 20.12

(Required) The time handling functions of time.h shall not be used.

MISRA C:2012 Rule-21.10

(Required) The Standard Library time and date functions shall not be used

MISRA C++ 2008 18-0-4

(Required) The time handling functions of library <ctime> shall not be used.

Code examples

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

#include <stddef.h>
#include <time.h>

time_t example(void) {
  return time(NULL);
}

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

void example(void) {
}