[previous] MISRA-C:2004  Rule  19.9:  (Required) [next] Arguments to a function-like macro shall not contain tokens that look like preprocessing directives.
If any of the arguments act like preprocessor directives, the behaviour when macro substitution is made can be unpredictable.

Example Code:


/* PRQA S 0434,0911,2214,3110,3417 ++ */
#include "misra.h"
#include "m2cmex.h"

#define SUM(A,B,C,D) ((A) + (B) + (C) + (D))            /* MISRA Violation - Rule 19.7 */

extern S16 test_1909( void )
{
#if 0

   /* QAC will not parse the following code.
      A syntax error will be generated if the
      code is not in an excluded block */

   s16a =  SUM(    5,
#ifdef SW                                               /* MISRA Violation */
                   s16b,
#else                                                   /* MISRA Violation */
                   s16c,
#endif                                                  /* MISRA Violation */
                   0   );

#endif
    return 1;
}


QAC messages that encompass this guideline:

0853 [U] Macro arguments contain a sequence of tokens that has the form of a preprocessing directive.


Related rules:

Rule  1.2 No reliance shall be placed on undefined or unspecified behaviour.



(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