Skip to main content

IAR Embedded Workbench for Arm 9.70.x

MISRAC2004-19.4

In this section:
Synopsis

(Required) C macros shall only expand to a braced initialiser, a constant, a string literal, a parenthesised expression, a type qualifier, a storage class specifier, or a do-while-zero construct.

Enabled by default

Yes

Severity/Certainty

Low/Medium

lowmedium.png
Full description

A macro definition was found that is not permitted.

Coding standards
MISRA C:2004 19.4

(Required) C macros shall only expand to a braced initializer, a constant, a string literal, a parenthesized expression, a type qualifier, a storage class specifier, or a do-while-zero construct.

Code examples

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

#define PLUS_TWO(X) (X) + 2

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

#define PLUS_TWO(X) ((X) + 2)