Skip to main content

IAR Embedded Workbench for RISC-V 3.40

MISRAC2004-19.10

In this section:
Synopsis

(Required) In the definition of a function-like macro each instance of a parameter shall be enclosed in parentheses unless it is used as the operand of # or ##.

Enabled by default

Yes

Severity/Certainty

High/Medium

highmedium.png
Full description

A macro parameter was not enclosed in parentheses or used as the operand of # or ##.

Coding standards
MISRA C:2004 19.10

(Required) In the definition of a function-like macro, each instance of a parameter shall be enclosed in parentheses unless it is used as the operand of # or ##.

Code examples

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

#define abs(x) ((x >= 0) ? x : -x)

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

#define abs(x) (((x) >= 0) ? (x) : -(x))