Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unnamed Structure and Union Fields #127

Open
studio8502 opened this issue Sep 24, 2021 · 0 comments
Open

Unnamed Structure and Union Fields #127

studio8502 opened this issue Sep 24, 2021 · 0 comments

Comments

@studio8502
Copy link

studio8502 commented Sep 24, 2021

In ISO C11, it's legal and useful to define a struct like

struct {
    int a;
    union {
        int b;
        float c;
    };
    int d;
} foo;

in such a case, an instance foo of struct bar would have foo.b and foo.c accessing the same memory as different types. In addition, it is also legal and useful to do this:

struct foo {
    int a;
};

struct bar {
    struct foo;
    float b;
    char *c;
};

in which case, a pointer to bar can be easily and safely cast to a pointer to foo, and an instance baz of struct bar would have member baz.a as an int.

Millfork already supports both structure and union types, and I feel that this ability would make it even better.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants