[previous] MISRA-C:2004  Rule  19.8:  (Required) [next] A function-like macro shall not be invoked without all of its arguments.
This is a constraint error, but preprocessors have been known to ignore this problem. Each argument in a function-like macro must consist of at least one preprocessing token otherwise the behaviour is undefined.

Example Code:


#include "misra.h"
#include "m2cmex.h"

#define MAX( A, B )   ( ( ( A ) > ( B ) ) ? ( A ) : ( B ) )
#define INC( X ) ( X + 1 )

extern S16 test_1908( void )
{
   S16 s16k;
   S16 s16m;

   s16k = MAX( s16a, 1 );
   s16k = s16k + MAX( s16a );         /* MISRA Violation */
   s16m = INC();                      /* MISRA Violation */

   return s16k + s16m;
}


QAC messages that encompass this guideline:

0850 [C99] Macro argument is empty.
0856 [C] Fewer arguments in macro call than specified in definition.


Related rules:

Rule  1.1 All code shall conform to ISO/IEC 9899:1990 C programming language, ISO 9899, amended and corrected by ISO/IEC 9899/COR1:1995, ISO/IEC 9899/AMD1:1995, and ISO/IEC 9899/COR2: 1996192



(c) The Motor Industry Research Association, 2004
QA C Source Code Analyser 8.1.2
MISRA-C:2004 Compliance Module 3.2
© 2013 Programming Research
www.programmingresearch.com
Personality Groups | Glossary | Message Index | MISRA-C:2004 Rule Index Contents