Skip to content

Unnamed Structure and Union Fields #127

@ghost

Description

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions