`enum x;` - what is it?

FeepingCreature feepingcreature at gmail.com
Wed Aug 19 14:55:27 UTC 2020


On Wednesday, 19 August 2020 at 14:43:22 UTC, Victor Porton wrote:
> On Wednesday, 19 August 2020 at 14:06:16 UTC, 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;
>>
>> ?
>
> Oh, found: "An empty enum body (For example enum E;) signifies 
> an opaque enum - the enum members are unknown."
>
> But what this "unknown" does mean? How "unknown" differs from 
> "none" in this context?
>
> The specification is unclear. It does not define the meaning of 
> unknown. I will submit a bug report.

It means exactly what it says. The compiler doesn't know what 
members are in the enum. So you can't declare a variable of it, 
you can't use it directly.. you can p much only use it in 
pointers.


More information about the Digitalmars-d-learn mailing list