Solved

valid enum?

Posted on 2016-08-10
6
83 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 45

Accepted Solution

by:
Kent Olsen earned 400 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 45

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 34

Assisted Solution

by:sarabande
sarabande earned 100 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

Technology Partners: 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!

Question has a verified solution.

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

An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
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 how to use strings and some functions related to them in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use for-loops in the C programming language.

691 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