enum for beginners

Mike Wey mike-wey at example.com
Tue Nov 15 12:37:05 PST 2011


On 11/14/2011 11:25 PM, Johannes Totz wrote:
> Hi!
>
> I'm having trouble with named typed enums.
> This works (unnamed):
>
> enum : string
> {
> a = "a",
> b = "b"
> }
>
> int main(string[] argv)
> {
> writeln(a);
> return 0;
> }
>
>
> But this does not:
>
> enum X : string
> {
> a = "a", // Error: Integer constant expression expected
> // instead of "a"
> b = "b" // Error: Integer constant expression expected
> // instead of "b"
> }
>
> int main(string[] argv)
> {
> writeln(X.a);
> return 0;
> }
>
>
> What did I miss?
>
>
> Johannes

It's a bug: string enums don't work with -g compiler switch.

http://d.puremagic.com/issues/show_bug.cgi?id=5168

-- 
Mike Wey


More information about the Digitalmars-d-learn mailing list