![]() |
|
MISRA C:2012 Rule-20.7: (Required) |
|
||||
![]() | |||||||
Amplification:
If the expansion of any macro parameter produces a token, or sequence of tokens, that form an expression then that expression, in the fully-expanded macro, shall either:
Note: this does not necessarily require that all macro parameters are parenthesised; it is acceptable for parentheses to be provided in macro arguments.
Example Code:
#include "misra.h"
#include "m3cmex.h"
#define MAXCONST 5 /* */
#define MAX1( A,B ) ((( A ) > ( B )) ? ( A ) : ( B )) /* 3453 */
#define MAX2( A,B ) ((( A > B ) ? A : B )) /* 3410 3453 */
extern int16_t rule_2007( void )
{
int16_t i;
int16_t j;
int16_t k = MAXCONST;
i = MAX1( s16a, s16b );
j = MAX2( s16a, s16b );
return i + j + k;
}
QAC messages that encompass this guideline:
| 3410 | Macro parameter not enclosed in (). |
|
||
(c) The Motor Industry Research Association, 2012
|
QA C Source Code Analyser 8.1.2
MISRA C:2012 Compliance Module 1.0 © 2013 Programming Research www.programmingresearch.com |
Personality Groups | Glossary | Message Index | MISRA C:2012 Rule Index | Contents |