Re: [AD] Proposal: removal of zero-sized arrays |
[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
onsdagen den 9 oktober 2002 23.35 you wrote:
> Advantages:
> - dat2c will work nicely :-)
Can be done in other ways as well. Won't it be necessary to call an
init-function if you introduce this?
> - 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)
Is this used by Allegro internally somewhere?
> - makes the code a little simpler in certain places (ie. the ZERO_SIZE
> macro in header files, etc)
Minor
> - AIUI zero-sized arrays are not ANSI C [1] (as always, please correct
> me if I'm wrong)
This is an important item. Think of people who wants to port Allegro or parts
of it to completly other platforms (maybe some hand-held object). Following
ANSI is good.
> Disadvantages:
> - requires somebody to do the work (I volunteer) and some work checking
> and applying
Seems to be fixed:-)
> - increases instance size by sizeof(void*) + alignment
... and the alignment cost will often be 0 (on all platforms where
alignment==sizeof(void*))
> - functions creating such structures require an extra line of code
Minor
To me it seems there are more advantages than disadvantages. To carry out the
ANSI- item only, changing 'char data[0]' to 'char data[1]' would be
sufficient.
/C