MISRA.CHAR.NOT_CHARACTER'char' is used for non-character value. MISRA-C Rule 6.1 (required): The plain char type shall be used only for the storage and use of character values.[Implementation 14] There are three distinct char types, (plain) char, signed char and unsigned char. signed char and unsigned char shall be used for numeric data and plain char shall be used for character data. The signedness of the plain char type is implementation defined and should not be relied upon. Character values/data are character constants or string literals such as 'A', '5', '\n', "a". Numeric values/data are numbers such as 0, 5, 23, \x10, -3. Character sets map text characters onto numeric values. Character values are the "text". The permissible operators on plain char types are the simple assignment operator (=), equality operators (==, !=) and explicit casts to integral types. Additionally, the second and third operands of the ternary conditional operator may both be of plain char type. MISRA-C++ Rule 5-0-11 (required): The plain char type shall only be used for the storage and use of character values.[Implementation 3.9.1(1), 7.1.5.2(1)] RationaleThe char type within C++ is defined for use with the implementation character set. It is implementation-defined if char is signed or unsigned, and it is therefore unsuitable for use with numeric data. Character values consist of character literals or strings. A character set maps text characters onto numeric values; the character value is the text itself. Note that Rule 3—9—2 applies, so this rule also covers the char_t type. Examplechar_t a = 'a'; // Compliant char_t b = '\r'; // Compliant char_t c = 10; // Non-compliant char d = 'd'; // Compliant with this rule, but breaks Rule 3—9—2 |