11-03-2014, 04:44 PM
I'm not 100% sure on the interpretation of rule 6.2 when it comes to using "unsigned char" values as labels for switch case.
Example:
For each of the "case " lines PC-lint (from V9.00j on) complains about a "Disallowed use of non-numeric value in a case label".
I would have considered defining and using the contants as "storage and use of numeric values" as described in 6.2.
I also can not find a similar limitation in MISRA-C 2012. Though I might not have looked deeply enough as I only have it in printed form.
Thanks for any feedback you might have on this.
Example:
Code:
const uint8_t CONSTANT_ONE = 12U;
const uint8_t CONSTANT_TWO = 34U;
uint8_t value = foo();
switch (value)
{
case CONSTANT_ONE:
[...]
break;
case CONSTANT_TWO:
[...]
break;
default:
[...]
break;
}
For each of the "case " lines PC-lint (from V9.00j on) complains about a "Disallowed use of non-numeric value in a case label".
I would have considered defining and using the contants as "storage and use of numeric values" as described in 6.2.
I also can not find a similar limitation in MISRA-C 2012. Though I might not have looked deeply enough as I only have it in printed form.
Thanks for any feedback you might have on this.
<t></t>