avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] zero length array in nocommon


From: bleverett
Subject: Re: [avr-gcc-list] zero length array in nocommon
Date: Thu, 24 Sep 2009 00:05:26 +0000

I used this for the exact same reason.  I really don't like seeing a lot of #if's in the code, and the zero-length array solved this problem beautifully.

That is, until I had to port the code to IAR.  That compiler does not honor zero-length arrays, so I had to add some #if's.  I came up with some macros that were helpful, but they made the code much harder to understand.  So we're back to lots of #if's in the code.

Blake
-------------- Original message from Ruud Vlaming <address@hidden>: --------------


> On Wednesday 23 September 2009 21:14, Joerg Wunsch wrote:
> > Ruud Vlaming wrote:
> >
> > > I noticed a strange behaviour when you place a zero length array in
> > > 'nocommon'.
> >
> > No idea why the behaviour changes, but as a note of warning: a
> > zero-length array is not allowed by the C standard.
> Well, mayby not in ISO C, but certainly in GNU C:
> http://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html
> thus at least the gcc compiler should be able to handle it :-)
>
> > No idea what you are trying to achieve here though.
> Although the link gives an example how this could be usefull,
> i found a different application. I configure my projects using
> preprop defines, and if a don't need an array internally, the size
> calculation simply produces a zero. That way no space is taken,
> and it is much easier than having if-defs around all arrays to see
> if they accedently have size zero. But it seems it does not work
> when they are not in the common space.
>
> This 'quirk' of gcc does not seem to be specifically avr related
> but probably we are the only one's left to care about the
> spoilled byte.
>
> Ruud.
>
>
> _______________________________________________
> AVR-GCC-list mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/avr-gcc-list

reply via email to

[Prev in Thread] Current Thread [Next in Thread]