Keil Logo

C51: DOES ENUM TYPE CHECKING WORK?

QUESTION

I use a lot of enums in my C code. Does the C compiler perform type checking for enums to validate? I need to know 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, C51 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: Friday, March 22, 2013


Did this article provide the answer you needed?
 
Yes
No
Not Sure
 
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.