?
Solved

valid enum?

Posted on 2016-08-10
6
Medium Priority
?
86 Views
Last Modified: 2016-08-10
enum
{
      REVERSE,
      FORWARD,

      NUM_ZONES
};

My embedded target board is based on Renesas RH850F1L Microcontroller.  My language is Embedded 'C'.

I get compile error "expected an identifier" when I create above enum.  Is it a valid enum?  
I want to use members of this enum to create an array and also use members of this enum for array index.

I can do #define instead but can this enum work in place of #define?
0
Comment
Question by:naseeam
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 46

Accepted Solution

by:
Kent Olsen earned 1600 total points
ID: 41750480
You might try naming the enumeration, though that's not a requirement.

enum direction_t
{
      REVERSE,
      FORWARD,
      NUM_ZONES
};

Are you duplicating a declaration?

enum direction_t
{
      DIR_REVERSE,
      DIR_FORWARD,
      DIR_NUM_ZONES
};


Kent
1
 
LVL 1

Author Comment

by:naseeam
ID: 41750646
I get the same error.  No, I'm not duplicating the declaration.
0
 
LVL 46

Expert Comment

by:Kent Olsen
ID: 41750770
REVERSE and FORWARD are pretty common words.  There's a reasonable chance that they could already be define in another #include file.

Can you post a few lines before and after the enum declaration?

Thanks!
1
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 35

Assisted Solution

by:sarabande
sarabande earned 400 total points
ID: 41750831
Are you duplicating a declaration?

actually it is a definition  of a constant or a preprocessor macro which must not be duplicated.

in c you may try

typedef enum
{
      DIR_FORWARD,
      DIR_REVERSE,
      NUM_DIRECTIONS
} EDIRECTION;

Open in new window


if the c compiler is not an ansi c compiler, it might be unable to use enum.

Sara
0
 
LVL 1

Author Comment

by:naseeam
ID: 41750868
Kent:

You were actually correct.  Your solution worked.
0
 
LVL 1

Author Closing Comment

by:naseeam
ID: 41750872
Thank you!
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
The goal of this video is to provide viewers with basic examples to understand recursion in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use switch statements in the C programming language.
Suggested Courses
Course of the Month9 days, 13 hours left to enroll

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question