[previous] 1404 [next] Enum object is being compared with an enum constant of a different enum type using a relational operator.
Arithmetic type - Enum types REFERENCE - ISO:C90-6.5.2.2 Enumeration Specifiers

An enum object is being compared with an enum constant from a different enumeration using a relational operator. Is this intended ?

For example:


/*PRQA S 1-9999 ++*/
/*PRQA S 1400, 1404, 1317, 1475 --*/

enum SIZE   { SMALL = 1, MEDIUM = 2, LARGE = 3 };
enum COLOUR { RED = 2, GREEN = 4, BLUE = 6 };

extern void foo(enum SIZE box)
{
   if (box == RED  ) { }        /* Message 1400        */
   if (box != GREEN) { }        /* Message 1400 + 1317 */

   if (box >  RED  ) { }        /* Message 1404        */
   if (box <  GREEN) { }        /* Message 1404 + 1475 */

   return;
}

See also:

QA·C Source Code Analyser 8.1.2
© 2013 Programming Research.
www.programmingresearch.com
Personality Groups | Glossary | Message Index Contents