www.digitalmars.com         C & C++   DMDScript  

D - [bug?] enum xxx : char[]

reply "C. Sauls" <ibisbasenji yahoo.com> writes:
Are enum's not allowed to derive from char[]?  The following generates 
the given errors:

------------------------------constants.d
  16: enum EXT : char[] {
  17:     version (Win32) {
  18:         SRC = "d",
  19:         OBJ = "obj",	
  20:         LIB = "lib"
  21:     }
  22:
  23:     version (linux) {
  24:         SRC = "d",
  25:         OBJ = "o",	
  26:         LIB = "a"
  27:     }
  28: }
------------------------------
constants.d(16): { enum members } expected
constants.d(16): Declaration expected, not '['

-C. Sauls
-Invironz
Apr 17 2004
next sibling parent reply J C Calvarese <jcc7 cox.net> writes:
C. Sauls wrote:
 Are enum's not allowed to derive from char[]?  The following generates 
 the given errors:
 
 ------------------------------constants.d
  16: enum EXT : char[] {
  17:     version (Win32) {
  18:         SRC = "d",
  19:         OBJ = "obj",   
  20:         LIB = "lib"
  21:     }
  22:
  23:     version (linux) {
  24:         SRC = "d",
  25:         OBJ = "o",   
  26:         LIB = "a"
  27:     }
  28: }
 ------------------------------
 constants.d(16): { enum members } expected
 constants.d(16): Declaration expected, not '['
 
 -C. Sauls
 -Invironz
I think enums are only allowed to be uint or int, but I'm not sure because "enum Name : type" hasn't been documented yet (or the documentation has been lost). -- Justin http://jcc_7.tripod.com/d/
Apr 17 2004
parent "Walter" <walter digitalmars.com> writes:
"J C Calvarese" <jcc7 cox.net> wrote in message
news:c5sea7$2mgk$1 digitaldaemon.com...
 C. Sauls wrote:
 Are enum's not allowed to derive from char[]?
No, only integral types. It's a bug in the documentation, and a bug in the compiler.
Apr 17 2004
prev sibling parent reply "Kris" <someidiot earthlink.dot.dot.dot.net> writes:
.. and you can't (currently) use version{} inside an enum; would be handy if
you could.

- Kris

"C. Sauls" <ibisbasenji yahoo.com> wrote in message
news:c5sbpb$2j3s$1 digitaldaemon.com...
 Are enum's not allowed to derive from char[]?  The following generates
 the given errors:

 ------------------------------constants.d
   16: enum EXT : char[] {
   17:     version (Win32) {
   18:         SRC = "d",
   19:         OBJ = "obj",
   20:         LIB = "lib"
   21:     }
   22:
   23:     version (linux) {
   24:         SRC = "d",
   25:         OBJ = "o",
   26:         LIB = "a"
   27:     }
   28: }
 ------------------------------
 constants.d(16): { enum members } expected
 constants.d(16): Declaration expected, not '['

 -C. Sauls
 -Invironz
Apr 17 2004
parent reply "Walter" <walter digitalmars.com> writes:
"Kris" <someidiot earthlink.dot.dot.dot.net> wrote in message
news:c5sg1p$2opt$1 digitaldaemon.com...
 .. and you can't (currently) use version{} inside an enum; would be handy
if
 you could.
Matthew argued for this as well, but I don't agree. Visually, it looks cluttered to put versions down at such a low level. Version differences should be at a higher level.
Apr 17 2004
parent "Kris" <someidiot earthlink.dot.dot.dot.net> writes:
Oh, I just meant that it could be convenient at times; I wouldn't want to
argue over such an idiosyncrasy when there's bigger fish to fry; such as
additional AA properties to pre-allocate and clear ... <g>



"Walter" <walter digitalmars.com> wrote in message
news:c5t4uo$o10$1 digitaldaemon.com...
 "Kris" <someidiot earthlink.dot.dot.dot.net> wrote in message
 news:c5sg1p$2opt$1 digitaldaemon.com...
 .. and you can't (currently) use version{} inside an enum; would be
handy
 if
 you could.
Matthew argued for this as well, but I don't agree. Visually, it looks cluttered to put versions down at such a low level. Version differences should be at a higher level.
Apr 18 2004