المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Enumerated Type Not Comparing Correctly



C++ Programming
10-01-2009, 08:51 AM
Hello. I'm writing some C code for an embedded application, and I've run into a problem wherein a compare against an enumerated value is not being executed correctly. Take the following code snippet, for example:

typedef unsigned int UINT16;
typedef enum enum_items_tag
{
ITEM_1,
ITEM_2,
ITEM_3,

/* ... */

ITEM_918,
MAX_ENUM_ITEMS
} enum_items_t;

UINT16 n;

for ( n = 0; n <span class="code-keyword">