Main Content

MISRA C:2023 Dir 4.6

typedefs that indicate size and signedness should be used in place of the basic numerical types

Since R2024a

Description

Directive Definition

typedefs that indicate size and signedness should be used in place of the basic numerical types.

Rationale

When the amount of memory being allocated is important, using specific-length types makes it clear how much storage is being reserved for each object.

Polyspace Implementation

The rule checker flags use of basic data types in variable or function declarations and definitions. The rule enforces use of typedefs instead.

The rule checker does not flag the use of basic types in the typedef statements themselves.

Troubleshooting

If you expect a rule violation but do not see it, refer to Diagnose Why Coding Standard Violations Do Not Appear as Expected.

Examples

expand all

typedef unsigned int uint32_t;

int x = 0;       /* Non compliant */
uint32_t y = 0;  /* Compliant */

In this example, the declaration of x is noncompliant because it uses a basic type directly.

Check Information

Group: Code design
Category: Advisory
AGC Category: Advisory

Version History

Introduced in R2024a