Does D support anonymous structs?
Sean Kelly
sean at f4.ca
Wed Feb 22 23:37:22 PST 2006
Derek Parnell wrote:
> On Wed, 22 Feb 2006 20:58:35 -0800, Sean Kelly wrote:
>>
>> ------------------------------------
>>
>> C:\code\d>type test.d
>> void main()
>> {
>> struct S
>> {
>> union
>> {
>> struct
>> {
>> int i1;
>> } s1;
>> } u;
>> }
>>
>> S s;
>> }
>
> The above doesn't work because if you have an anonymous struct/union is
> *must not* have a name - that's why its anonymous. Consequently, you can
> only have one anonymous aggregate per parent aggregate.
Thanks. I ran into this porting C code, which allows anonymous named
structs like the above. I was hoping I wouldn't have to invent one-off
names for the structs, but it's not a big deal either way.
Sean
More information about the Digitalmars-d
mailing list