3 ms·
I got the impression it was a GCC extension because it's listed in the "C Extensions" of the GCC documentation ( https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.
by maxlybbert 10y ago
I got the impression it was a GCC extension because it's listed in the "C Extensions" of the GCC documentation ( https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html ).
EDIT: the FAQ actually refers to arrays of one element where GCC makes a big deal about saving memory by accepting zero-length arrays. But you are correct that this kind of cleverness wasn't limited to GCC ( https://blogs.msdn.microsoft.com/oldnewthing/20031212-00/?p=41523 https://blogs.msdn.microsoft.com/oldnewthing/20031212-00/?p=... , https://blogs.msdn.microsoft.com/oldnewthing/20040826-00/?p=38043 https://blogs.msdn.microsoft.com/oldnewthing/20040826-00/?p=... ).
- comex 10y agoThree different ways to declare an array at the end of a structure: [1] is the old school approach, which is still honored by compilers despite indexing past the first element technically being undefined behavior. [0] is a GCC extension. [] is C99.