User:Arcturus4669/wip

C struct data types may end with a flexible array member  with no specified size:

Such structures typically serve as the header in a larger, variable memory allocation:

The  operator on such a   gives the size of the structure as if the flexible array member was empty. This may include padding added to accommodate the flexible member; the compiler is also free to re-use such padding as part of the array itself.

is commonly used as the allocation size.

This is not wrong, however it may allocate a few more bytes than necessary: the compiler may be re-purposing some of the padding that is included in. Should this be a concern, macros exist to compute the minimum size while ensuring that the compiler's padding is not disrupted.

As the array may start in the padding before the end of the structure, its content should always be accessed via indexing or  , not.

Flexible array members were officially standardized in C99, however it was already common to declare a zero-sized array member with the same effect. The GCC compiler explicitly accepts zero-sized arrays for such purposes. C++ does not have flexible array members.