`enum x;` - what is it?

Steven Schveighoffer schveiguy at gmail.com
Wed Aug 19 14:18:28 UTC 2020


On 8/19/20 10:06 AM, Victor Porton wrote:
> This declaration does compile:
> 
> enum x;
> 
> But what is it? Is it an equivalent of
> 
> enum x { }
> 
> ?
> 
> What in the specification allows this looking a nonsense
> 
> enum x;
> 
> ?

I use it as a symbol for UDAs.

enum required;

struct S
{
    @required int x;
}

which can then easily be found.

What is it? I have no idea. I'm just using the name.

I think it's treated as a forward declaration. Kind of like

void foo();

-Steve


More information about the Digitalmars-d-learn mailing list