[asterisk-dev] gcc bug with zero-sized arrays and struct initializers.

Tony Mountifield tony at softins.clara.co.uk
Tue Oct 30 11:17:58 CDT 2007


In article <20071030061129.A88162 at xorpc.icir.org>,
Luigi Rizzo <rizzo at icir.org> wrote:
> On Tue, Oct 30, 2007 at 12:51:56PM +0000, Tony Mountifield wrote:
> > Why would you want an element AFTER a zero-sized array? In the above
> > example, pre[0] would occupy the same storage as a.
> > 
> > Surely the zero-sized array is supposed to be the final item in the struct,
> > so that the struct defines the fixed part and the array then identifies the
> > beginning of the variable-length part.
> 
> asterisk's stringfields
> 
> http://svn.digium.com/view/asterisk/trunk/include/asterisk/stringfields.h?view=log
> 
> are defined using macros, and the wrapper code (macro
> AST_DECLARE_STRING_FIELDS() ) places a zero-size array as a marker
> before the first element, and a zero-size array as a marker after
> the last element.  Macros then do pointer arithmetics using the
> start marker.

OK, I see what you mean now. The zero-sized arrays are effectively acting
just as labels.

Thanks!

Cheers
Tony
-- 
Tony Mountifield
Work: tony at softins.co.uk - http://www.softins.co.uk
Play: tony at mountifield.org - http://tony.mountifield.org



More information about the asterisk-dev mailing list