[previous] MISRA-C:2004  Rule  12.10:  (Required) [next] The comma operator shall not be used.
Use of the comma operator is generally detrimental to the readability of code, and the same effect can be achieved by other means.

Example Code:


/* PRQA S 2984 ++ */

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

#define A (-5)
#define B 3

extern S16 test_1210( void )
{
   S16 x;
   S16 y;
   S16 i;

   y = ( x = A, x + B );              /* MISRA Violation */

   for ( i = 0, ++y; i < B; ++i )     /* MISRA Violation */
   {
      ++y;
   }

   return y;
}


QAC messages that encompass this guideline:

3417 The comma operator has been used outside a 'for' statement.
3418 The comma operator has been used in a 'for' statement.



(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