Użytkownik Jonathan Wakely napisał:
2011/12/10 Krzysztof Żelechowski:
{ int x [] = {}; }
Why is it valid and what does it mean?
It's the GNU zero-length array extension:
http://gcc.gnu.org/onlinedocs/gcc-4.6.2/gcc/Zero-Length.html
I believe it's equivalent to:
int x[0] = { };
Even if it is, it is undocumented that zero-length arrays need not be
struct members. The example only shows it inside a struct where its
length is not inferred.
I can think of an application of this device in the following way:
#ifdef HAVE_DATA
#define DATA 0, 01, 02, 03
#else
#define DATA
#endif
int x [] = { DATA };
It still looks esoteric (and undocumented).
Chris