13-03-2015, 08:45 AM
This is alright because K1 is declared as an anonymous enumeration type enum { K1=1, K2=128 };
Section 8.10.2 lists the possible essential type categories. This includes the following note.
Section 8.10.2 lists the possible essential type categories. This includes the following note.
Quote: Another exception is the use of anonymous enumerations as defined in Appendix D. Anonymous enumerations are a way of defining a set of related constant integers and are consider to have an essentially signed type.Appendix D.5 gives the definition of anonymous enum type as
Quote:An anonymous enum type is an enumeration which does not have a tag and which is not used in the definition of any object, function or type.Appendix D.6 gives the type of anonymous enum constants as
Quote:The following anonymous enum type defines a set of constants. The essential type of each constant is the STLR. Therefore on a machine with 8-bit char and 16-bit short types, A and B have an essential type of signed char but C has an essential type of signed short.The essential type of the K1 enumeration constant is therefore determined as the STLR of the literal "1", which means that the essential type of K1 is signed char.
enum { A = 8, B = 64, C = 128 };
Posted by and on behalf of the MISRA C Working Group