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 CCS Technical Support

enum musings

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



Joined: 18 Oct 2009
Posts: 27
Location: Australia

View user's profile Send private message

enum musings
PostPosted: Tue Mar 02, 2010 9:27 pm     Reply with quote

You might look at this ccs thread and ask many questions

https://www.ccsinfo.com/forum/viewtopic.php?t=23400

Now I will show some interesting enum statements that compile with ccs.



1. enum{u,v,w};

2. enum {a,b,c} *ep;

3. enum ee{x,y,x}*ez;

4. enum xy{i,j,k}uv;

5.enum {a=0xFFFFFFFF};

6.enum{a=0xFFFFFFFF}ep;

7.enum{a=4294967298}ep; // Compiles in #device ANSI mode (signed)why ?????

8. enum{a=0b11111111111111111111111111111111}ep; //Compiles in #device ANSI mode (signed) why?????

9.enum{a=-2147483649}ep;//Compiles in #device ANSI mode (signed) why?????

10. enum{a=-214748364987654321}ep;//Compiles in #device ANSI mode (signed) why?????

11. enum{a=023}ep; //Octal representation

12. enum{a=023}*ep; //Octal representation

13. enum{q=-2.51432};

14. enum{q='u'};

15. enum{a=023+1.1257-0x555+0b101110}ep;





Those that do not compile

1. enum {a=0xFFFFFFFF}*ep;

*** Error 84 : Pointers to bits are not permitted

2.enum{a=0x100000000}ep;

***Error 103 : Constant out of the valid range

enum{a=040000000000}ep; //Octal representation

***Error 103 : Constant out of the valid range



CCS compiler version 4.104 PCH command-line running in MPLAB. Processor PIC18F8722


Any questions or discussions on the above statements?

C Enumeration Declarations

http://msdn.microsoft.com/en-us/library/whbyts4t.aspx
_________________
Clear Logic


Last edited by Gavin Pinto on Wed Mar 03, 2010 4:00 pm; edited 4 times in total
Gavin Pinto



Joined: 18 Oct 2009
Posts: 27
Location: Australia

View user's profile Send private message

PostPosted: Wed Mar 03, 2010 6:06 am     Reply with quote

compiler version PCH 4.104
_________________
Clear Logic


Last edited by Gavin Pinto on Tue Jul 20, 2010 6:55 pm; edited 1 time in total
Wayne_



Joined: 10 Oct 2007
Posts: 681

View user's profile Send private message

PostPosted: Wed Mar 03, 2010 6:25 am     Reply with quote

Octal representation begins with a 0 not an O
Gavin Pinto



Joined: 18 Oct 2009
Posts: 27
Location: Australia

View user's profile Send private message

PostPosted: Wed Mar 03, 2010 6:38 am     Reply with quote

Wayne_ wrote:
Octal representation begins with a 0 not an O


True. Thanks

A Typo I tested it with 0 not O. I have corrected listing above
_________________
Clear Logic
GPinto
Guest







PostPosted: Thu Mar 04, 2010 10:40 pm     Reply with quote

I will now examine what is actually in the enumerated constants as no type checks were done and compiler accepted all sorts of big or wrong values
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