Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Do enumerators count as "numeric values"?
#2
This line appears in Rule 6.2 which concerns the values that can be stored in signed and unsigned char types.

Enumerators count as numeric values provided that the value can be represented in the signed or unsigned char type.

Code:
enum colour { red = 0, amber = 127, green = 255};
signed char s1 = red;          /* Compliant     */
signed char s2 = amber;        /* Compliant     */
signed char s3 = green;        /* Non-compliant */
A future version of MISRA C may place further restrictions on the use of enumerators.
Posted by and on behalf of the MISRA C Working Group
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 4 Guest(s)