Keil™, An ARM® Company

Technical Support

C166: ENUM TYPE CHECKING


Information in this article applies to:

  • C166 Version 4.02

QUESTION

I use a lot of enums in my C code. I need to know if the C compiler performs type checking for enums to validate that I'm using correct enums for certain variables. For example:

enum apple { MAC, GRANNY, WASH_ST };
enum pear { GREEN, BROWN, BARTLETT };

static void func(enum apple a, enum pear p);

func (BARTLETT, MAC);

The above code generates no warnings when BARTLETT is passed for the enum apple parameter. Is this correct?

ANSWER

Yes. This is correct. Currently, C166 does not perform type checking for enumerations.

PC-Lint performs this type of error checking and it can easily be integrated into the µVision IDE.

Last Reviewed: Wednesday, June 09, 2004


Did this article provide the answer you needed?
 
Yes
No
Not Sure