logoalt Hacker News

uecker • today at 4:01 PM • 2 replies • view on HN

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).


Replies

lukasgelbmann • today at 4:09 PM

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.

➕ show 2 replies
randomNumber7 • today at 4:48 PM

What happens when I put a variable of a struct type that contains a flexible array member on the stack?

➕ show 1 reply