Solved

valid enum?

Posted on 2016-08-10
6
74 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
  • 3
  • 2
6 Comments
 
LVL 45

Accepted Solution

by:
Kdo 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:Kdo
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
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 
LVL 33

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

ScreenConnect 6.0 Free Trial

At ScreenConnect, partner feedback doesn't fall on deaf ears. We collected partner suggestions off of their virtual wish list and transformed them into one game-changing release: ScreenConnect 6.0. Explore all of the extras and enhancements for yourself!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How do I test for current date? 9 105
difference between mmap and malloc/valloc + mmap fixed 18 260
chcp 65001 File encoding 66 247
Handling string inputs in C/Linux 23 185
Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
The goal of this video is to provide viewers with basic examples to understand opening and writing to files in the C programming language.
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.

825 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