Skip to main content

IAR Embedded Workbench for RX 5.20

MISRAC2012-Rule-21.24

In this section:
Synopsis

(Required) The random number generator functions of <stdlib.h> shall not be used

Enabled by default

Yes

Severity/Certainty

Low/Medium

lowmedium.png
Full description

Uses of srand, rand were found.

Coding standards
MISRA C:2012 Rule-21.24

(Required) The random number generator functions of <stdlib.h> shall not be used

Code examples

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

#include <stdlib.h>

int example() {
    int r = rand(); /* Non-compliant */
    return r;
}

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

void example(void) {
}