Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!border3.nntp.dca.giganews.com!Xl.tags.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local2.nntp.dca.giganews.com!nntp.supernews.com!news.supernews.com.POSTED!not-for-mail NNTP-Posting-Date: Mon, 22 Oct 2012 10:13:05 -0500 From: Steve Thompson Newsgroups: comp.lang.c Subject: Re: Compatibility question Date: Mon, 22 Oct 2012 02:28:43 +0000 Organization: Friends of the Galactic Collective Message-ID: References: <0.a87a1c8a472d870b0466.20121022022701BST.87y5izxpne.fsf@bsb.me.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit User-Agent: NN 6.4.3 Lines: 56 X-Trace: sv3-WfPMIo7XwxTM3sCCNVpzfDIw+lcovntU5jOeiMJ3OTAXDljgRVK8FRgO5YMVjhJeGlsb9TMytiz3kSP!14DKRL6vya2GNJIqZEYGjj9g23mmd52rLdLiwj4fxDleqx5V0WrtUj70ZYIv0A== X-Complaints-To: www.supernews.com/docs/abuse.html X-DMCA-Complaints-To: www.supernews.com/docs/dmca.html X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.40 X-Original-Bytes: 3465 Xref: csiph.com comp.lang.c:27508 On Mon, Oct 22, 2012 at 02:27:01AM +0100, Ben Bacarisse wrote: > Steve Thompson writes: > > > On Mon, Oct 22, 2012 at 12:29:08PM +1300, Ian Collins wrote: > >> On 10/22/12 11:54, Steve Thompson wrote: > > >> >Now that I've noticed that the GCC documentation has been updated (I > >> >may not have read that section for ten years, now that I think of it), > >> >it does indeed say that the C99 standard includes support for flexible > >> >arrays, with similar semantics to the old gcc zero subscript hack, so > >> >I will use that. > >> > >> You can't use a VLA as a structure member (how would you declare it?). > > > >>From the GCC info pages: > > > > In ISO C99, you would use a "flexible array member", which is slightly > > different in syntax and semantics: > > > > * Flexible array members are written as `contents[]' without the `0'. > > > > * Flexible array members have incomplete type, and so the `sizeof' > > operator may not be applied. As a quirk of the original > > implementation of zero-length arrays, `sizeof' evaluates to zero. > > > > * Flexible array members may only appear as the last member of a > > `struct' that is otherwise non-empty. > > > > * A structure containing a flexible array member, or a union > > containing such a structure (possibly recursively), may not be a > > member of a structure or an element of an array. (However, these > > uses are permitted by GCC as extensions.) > > > > So I'm free and clear. My VLAs will be in structures which are not > > encapsulated in other structures. > > There's a terminology confusion here. Your flexible array member is > just that, it's not a VLA. Variable length arrays are not permitted in > structs and flexible array members can only appear, unsurprisingly, in a > struct. I suppose so. Simply stated, anytime I use "something foo[]", it will usually be at the end of a struct. Good enough? Really, you ought to have read what I meant, rather than reading what I wrote. Regards, Steve Thompson -- GOTO's are like guns. Safety is entirely contingent on the user.