Unnamed Structure and Union Fields
- Dominant language
- Scala
- Stars
- 279
- Forks
- 21
- PR merge metrics
- No merged PRs in 30d
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.
Contributor guide
Research direction
The issue names no files or tests; start by locating Millfork's existing structure and union type handling. Done means supporting the two ISO C11-style unnamed structure and union forms, including the member access and embedding behavior described in the examples.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, scala
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100