Re: [AD] Proposal: removal of zero-sized arrays

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


> As the title says, I propose that we remove zero-sized arrays from the
> library.

Allegro doesn't strictly use zero-sized arrays: it uses arrays with
un-determined length in terminal position inside non-empty structures. All
the compilers targeted by Allegro (Watcom, Borland, MSVC) have supported
this extension for a long time, except the GNU C compiler. For the latter,
we rely on a custom extension, zero-sized arrays.

>  - more generally, it is possible to statically-initialise structures
>    with zero-sized arrays (you might want to do this for sub bitmaps
>    etc. to make sure that their creation never fails, thus simplifying
>    your code)

Don't you want to remove zero-sized arrays ?

>  - makes the code a little simpler in certain places (ie. the ZERO_SIZE
>    macro in header files, etc)

Huh... this extension makes things simpler: you don't have to bother with an
offset all over the place. And what's the problem with the ZERO_SIZE_ARRAY
macro ? Only the one who implements it has to know how it works internally.

>  - AIUI zero-sized arrays are not ANSI C [1] (as always, please correct
>    me if I'm wrong)

Right, but "arrays with un-determined length in terminal position inside
non-empty structures" are ISO C99: they are called flexible array members.
That's all what we need.

--
Eric Botcazou



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/