![]() |
![]() |
1414 | ![]() |
||||
![]() | |||||||
| Arithmetic type - Enum types | REFERENCE - ISO:C90-6.5.2.2 Enumeration Specifiers | ||||||
An enum object is being compared (using a relational operator) with the value of a constant expression which is not one of the enum constants . If the value of the constant expression is the same as one of the enum constants, perhaps it would be better to use the symbolic constant instead ? For example:
/*PRQA S 1-9999 ++*/
/*PRQA S 1414, 1317, 1410, 1475, 1476 --*/
enum SIZE { SMALL = 2, MEDIUM = 4, LARGE = 6 };
extern void foo(enum SIZE box)
{
if (box == LARGE ) { } /* */
if (box == 4 ) { } /* Message 1410 */
if (box != (2 + 3) ) { } /* Message 1410 + 1317 */
if (box <= MEDIUM ) { } /* */
if (box > 2 ) { } /* Message 1414 */
if (box < (4 + 3) ) { } /* Message 1414 + 1475 */
if (box < 2 ) { } /* Message 1414 + 1476 */
}
See also:
![]() | ||
| QA·C Source Code Analyser 8.1.2
© 2013 Programming Research. www.programmingresearch.com | Personality Groups | Glossary | Message Index | Contents |