Skip to content

Conversation

lawm
Copy link

@lawm lawm commented Jul 24, 2025

Adds nested struct and union definitions.

See WerWolv/ImHex#2197 and WerWolv/ImHex#363

There are no unit tests and I'm not familiar with the codebase. Please edit this pull request as needed.

lawm added 3 commits July 23, 2025 18:35
This allows defining structs and unions inside another struct definition.

Example:
```c
struct a {
  u32 i ;
  struct b {
    u32 ii;
  };
  u32 ia;
  union u {
    u32 ui;
    char uc[4];
  };
  //u au; // warning: this will add another member of the union
};
a a @ 0;
```

The syntax is not exactly the same as C, and it's not anonymous, but at
least you don't need to move the definition out.
Example:
```
struct a {
    struct {
        u32 ii;
    };
    union {
        u32 ui;
        char uc[4];
    };
}
```
```c
struct a {
    struct {
        u32 ii;
    } sname;
    union u {
        u32 ui;
        char uc[4];
    } uname;
}
```
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

Successfully merging this pull request may close these issues.

1 participant