top | item 36318569

(no title)

aloisklink | 2 years ago

Even better, you can use [C99 Flexible array members][1], e.g. something like:

    struct KeyedEntry {
      struct Entry entry;
      char key[]; // flexible array member
    };
It's not too much more useful when just using `char`, but for other data types, it's a bit cleaner, since it handles alignment/padding better.

[1]: https://en.wikipedia.org/wiki/Flexible_array_member, or https://beej.us/guide/bgc/html/split/structs-ii-more-fun-wit...

_Edit_: Something like this might not be suitable for the author, since they did mention how they wanted each `struct` to have a fixed size.

discuss

order

No comments yet.