Hacker News new | past | comments | ask | show | jobs | submit login

you can do this now in ISO C11 with the inclusion of anaonomous structures and unions.

    struct A { 
        int x, y; 
    };

    struct B {
        union {
            struct A 2d;
            struct { int x, y; };
        }
        int z;
    };

    ...

    struct B foo;
    foo.x = foo.2d.y = foo.z = 0;
you can access x and y as members of B or A.



Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: