[previous] 3452 [next] The replacement list of object-like macro '%s' is not enclosed in ().
Macro Definition

This object-like macro appears to expand to an arithmetic expression which is not parenthesized. Confusion could arise if the macro is used in a context where operators are adjacent to the macro and operator precedence becomes significant.

Message 3452 is generated when an object-like macro contains an operator (other than # or ##) and the operator is not bounded within the replacement list by either ( ), [ ], { } or < >,

For example:


/*PRQA S 3120,3199,3203,3361,3395,3401,3408,3412,3447,3459 ++ */

#define A       -5                                      /* Message 3452 */
#define B       x + y                                   /* Message 3452 */
#define C       (x + y)                                 /*              */
#define D       [x + y]                                 /*              */
#define E       do {x++; y++; z = x + y;} while (0)     /*              */

extern int x;
extern int y;
extern int z;

extern void foo(void)
{
    int r;

    r = 2 * B;

    E;
}


MISRA-C:2004 Rules applicable to message 3452:

Rule  19.4  (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.


See also:

QA·C Source Code Analyser 8.1
MISRA-C:2004 Compliance Module 3.2
© 2012 Programming Research.
www.programmingresearch.com
Personality Groups | Glossary | Message Index | MISRA-C:2004 Rule Index Contents