[previous] 3410 [next] Macro parameter not enclosed in ().
Macro Definition

In some macros, it is important for a parameter to be enclosed in parentheses within the replacement list. This is not the case for all macros or all parameters; it depends on how the parameter is used within the macro.

The problem arises when a macro parameter is used as an operand in certain kinds of expression. Consider the following example:


/*PRQA S 2017,3120,3198,3227,3390,3395,3401,3408,3429,3435,3453,3456 ++*/

#define SQUARE(A) (A * A)               /* Message 3410 */

extern int foo(int n)
{
    int r;
    r = SQUARE(n);
    r = SQUARE(n + 2);                  /* Message 3430 */
    return r;
}

See also:

QA·C Source Code Analyser 8.1.2
© 2013 Programming Research.
www.programmingresearch.com
Personality Groups | Glossary | Message Index Contents