View previous topic :: View next topic |
Author |
Message |
Gavin Pinto
Joined: 18 Oct 2009 Posts: 27 Location: Australia
|
enum musings |
Posted: Tue Mar 02, 2010 9:27 pm |
|
|
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
|
|
Posted: Wed Mar 03, 2010 6:06 am |
|
|
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
|
|
Posted: Wed Mar 03, 2010 6:25 am |
|
|
Octal representation begins with a 0 not an O |
|
|
Gavin Pinto
Joined: 18 Oct 2009 Posts: 27 Location: Australia
|
|
Posted: Wed Mar 03, 2010 6:38 am |
|
|
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
|
|
Posted: Thu Mar 04, 2010 10:40 pm |
|
|
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 |
|
|
|