IBM extension
Zero-extent array members

A zero-extent array is an array with no dimensions. Like a flexible array member, a zero-extent array can be used to access a variable-length object.

A zero-extent array must be explicitly declared with zero as its dimension:

array_identifier[0]

Like a flexible array member, a zero-extent array can be declared in any part of a structure, not just as the last member.

C++ only The type of any member that follows the zero-extent array must be compatible with the type of the zero-extent array.

C only The type of any member following the zero-extent array is not required to be compatible with the type of the zero-extent array; however, a warning is issued in this case.

Unlike a flexible array member, a structure containing a zero-extent array can be a member of another array. Also, the sizeof operator can be applied to a zero-extent array; the value returned is 0.

A zero-extent array can only be statically initialized with an empty set. For example:

struct foo{
   int a;
   char b[0];
}; bar = { 100, { } };

Otherwise, it must be initialized as a dyamically-allocated array.

Zero-extent array members can only be initialized if they are contained in the outermost part of nested structures. Members of inner structures cannot be initialized.

End of IBM extension


[ Top of Page | Previous Page | Next Page | Contents | Index ]