CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Global/local use of enum

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
object01



Joined: 13 May 2004
Posts: 90
Location: Nashville, TN

View user's profile Send private message Send e-mail Visit poster's website

Global/local use of enum
PostPosted: Tue Sep 28, 2004 9:59 am     Reply with quote

Why doesn't this work in CCS...

Code:
#include <18F2320.h>
enum Colors {red, green, blue};
void main() {
   enum Colors c;
}


But this does?

Code:
#include <18F2320.h>
void main() {
   enum Colors {red, green, blue};
   enum Colors c;
}


--
Jeff S.
Guest








Re: Global/local use of enum
PostPosted: Tue Sep 28, 2004 10:56 am     Reply with quote

object01 wrote:
Why doesn't this work in CCS...

Code:
#include <18F2320.h>
enum Colors {red, green, blue};
void main() {
   enum Colors c;
}


But this does?

Code:
#include <18F2320.h>
void main() {
   enum Colors {red, green, blue};
   enum Colors c;
}


--
Jeff S.

I'd suspect the keyword, is 'scope'. The identifier, must be 'in scope' for the declaration to work. Traditionally, an object declared outside a routine, is 'global', and 'in-scope', for the whole program. CCS handles this for variable names (a variable called 'fred' declared outside the routines, is given the label 'fred', while a variable called 'fred', declared inside main, is given the label 'main.fred', and the search rules try looking for this definition first, then move 'out' to the one outside), but it would appear, does not do this, for the enum definition, and will only find the one that is in the same area.....
The defintion _should_ follow the standard scope rules, so this is a definate 'error'.

Best Wishes
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group