![]() |
![]() |
3410 | ![]() |
||||
![]() | |||||||
| 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;
}
MISRA-C:2004 Rules applicable to message 3410:
| Rule 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 ##. |
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 |