Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

The bit after `>` is a quote, not my words. See https://en.cppreference.com/w/c/language/array for the source

It's saying that C99 implemented flexible array members but before then some compilers introduced their own (nonstandard) implementation of flexible array members, using the (not allowed) zero sized array notation.



The sequence of event was basically:

1. Pre-C99, no flexible array was allowed.

2. Gradually, people started using the "size-1 array at the end of a sturct but write beyond" hack as flexible array.

3. As an attempt to do the hack in a more ordered manner, some compilers, including GCC, started officially supporting the non-standard "size-0" array extension.

4. C99 added flexible array with indefinite length (array[]), while prohibiting both the undefined-behavior "array[1]" and the non-standard extentios "array[0]".

So when people say "size-0" array, it could mean either of these three things, and it does get a bit confusing. But fundamentally the idea was the same, all of the three techniques are used to achieve the same practical effect.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: