[Kstars-devel] branches/kstars/unfrozen/kstars/kstars

Jason Harris kstars at 30doradus.org
Tue Jul 1 08:09:39 CEST 2008


SVN commit 826641 by harris:

Interesting-yet-annoying C++ Trivia:

If you declare an enum thusly:

typedef enum { MERCURY, VENUS, MARS, JUPITER, SATURN, URANUS, NEPTUNE, PLUTO, 
SUN, MOON } PLANET;

there's *no* guarantee that the integers assigned to each item will be 
consecutive.  They *usually* are, but just for fun, sometimes they aren't!  In my 
case, the first 9 items were assigned consecutive numbers 0-8, and then the MOON 
item was assigned to 12!  

That's the last time I trust g++ to count to 9, I guess...
Argh.

CCMAIL: kstars-devel at kde.org



 M  +1 -1      ksplanetbase.h  


--- branches/kstars/unfrozen/kstars/kstars/ksplanetbase.h #826640:826641
@@ -28,7 +28,7 @@
 
 #include "trailobject.h"
 
-typedef enum { MERCURY, VENUS, MARS, JUPITER, SATURN, URANUS, NEPTUNE, PLUTO, SUN, MOON, UNKNOWN_PLANET } PLANET;
+typedef enum { MERCURY=0, VENUS=1, MARS=2, JUPITER=3, SATURN=4, URANUS=5, NEPTUNE=6, PLUTO=7, SUN=8, MOON=9, UNKNOWN_PLANET } PLANET;
 
 class QPoint;
 class KSNumbers;


More information about the Kstars-devel mailing list