On Tue, 15 Nov 2011 11:15:01 -0500, Johannes Totz <johan...@jo-t.de> wrote:

On 15/11/2011 15:56, Steven Schveighoffer wrote:
On Tue, 15 Nov 2011 10:55:44 -0500, Steven Schveighoffer
<schvei...@yahoo.com> wrote:

On Tue, 15 Nov 2011 10:47:22 -0500, Johannes Totz <johan...@jo-t.de>
wrote:
Ah, when I compile on the command line with:

dmd -g -debug main.d

main.d(6): Error: enum main.X base type must be of integral type, not
char[]
main.d(8): Error: cannot implicitly convert expression ("a") of type
char[1u] to int
main.d(9): Error: cannot implicitly convert expression ("b") of type
char[1u] to int

dmd must map to a D1 version, where string literals were char[N], not
immutable(char)[]. In D1, you could not have enums that were strings.

to check, type dmd without args on the command line, it will tell you
the version.

There is a 1.071 version somewhere in the path...
C:\Users\...>dmd
DMD32 D Compiler v1.071

But if I do...
C:\Users\...>C:\D\dmd2\windows\bin\dmd.exe -g -debug main.d
main.d(8): Error: Integer constant expression expected instead of "a"
main.d(9): Error: Integer constant expression expected instead of "b"
main.d(8): Error: Integer constant expression expected instead of "a"
main.d(9): Error: Integer constant expression expected instead of "b"

However...
C:\Users\...>C:\D\dmd2\windows\bin\dmd.exe main.d
C:\Users\...>main.exe
a


Getting rid of 1.071...
C:\Users\...>dmd
DMD32 D Compiler v2.056

C:\Users\...>dmd -g -debug main.d
main.d(8): Error: Integer constant expression expected instead of "a"
main.d(9): Error: Integer constant expression expected instead of "b"
main.d(8): Error: Integer constant expression expected instead of "a"
main.d(9): Error: Integer constant expression expected instead of "b"

Don't have a windows box handy, but this works on Linux:

steves@steve-laptop:~/testd$ cat testenum.d
import std.stdio;

enum X : string {
    a = "a",
    b = "b",
}

void main()
{
    writeln(X.b);
}
steves@steve-laptop:~/testd$ ~/dmd-2.056/linux/bin32/dmd -g -debug testenum.d
steves@steve-laptop:~/testd$ ./testenum
b

Can you post your exact code that doesn't work with dmd 2.056? This is all I have from your previous post. I can't see why it wouldn't work.

-Steve

Reply via email to