MISRA C:2012 Rule 7.5
The argument of an integer constant macro shall have an appropriate form
Since R2024a
Description
Rule Definition
The argument of an integer constant macro shall have an appropriate form.
This rule comes from MISRA C™: 2012 Amendment 3.
Rationale
Using an inappropriate form of an argument for an integer constant macro can lead to compilation errors or undefined behavior of the code for reasons such as unexpected substitutions, lack of type checking, and confusion of the compiler's assumptions and optimizations.
Polyspace Implementation
The rule checker reports a rule violation when using an inappropriate form of an argument of an integer constant macro. The form of an argument of an integer constant macro is considered appropriate if:
The argument is an unsuffixed integer literal such as a decimal, octal, or hexadecimal.
The value of the argument does not exceed the limits for the equivalent exact-width type that the name of the macro indicates. For example, the argument to
UINT32_C
must be representable as an unsigned 32-bit value.
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
Check Information
Group: Literals and Constants |
Category: Mandatory |
AGC Category: Mandatory |
Version History
Introduced in R2024a