This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: empty initialisers for arrays of inferred size


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]