Comment by uecker
7 hours ago
I do not get the connection with a VLA in this context, but if you need a VLA, by all means use it. It is basically always better than the alternative.
7 hours ago
I do not get the connection with a VLA in this context, but if you need a VLA, by all means use it. It is basically always better than the alternative.
> I do not get the connection with a VLA in this context
The article uses a struct with a VLA as the last element.
I see. This array of unknown length at the end of a struct is called a flexible array member and not a variable length array (although it also refers to an array of variable length it is a different language feature).
Yes, and variable length arrays were made an optional part of the standard in C11. Whereas flexible array members remain a standard required feature.
Flexible array members don’t allocate a dynamic amount of memory on the stack.
3 replies →
What happens when I put a variable of a struct type that contains a flexible array member on the stack?
1 reply →