ARM Technical Support Knowledge Articles

ENUM TYPE CHECKING

Applies to: C166 C Compiler

Answer


Information in this article applies to:


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 uVision IDE.

Article last edited on: 2004-06-09 15:47:52

Rate this article

[Bad]
|
|
[Good]
Disagree? Move your mouse over the bar and click

Did you find this article helpful? Yes No

How can we improve this article?

Link to this article
Copyright © 2011 ARM Limited. All rights reserved. External (Open), Non-Confidential