Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail From: Uncle Steve Newsgroups: comp.lang.c Subject: Re: Non-constant initializers Date: Sat, 14 May 2011 16:57:07 -0400 Organization: Friends of the Galactic Collective Lines: 85 Message-ID: References: <0ca8ca5b-e73e-418a-935f-0fcc17fdf404@q14g2000prh.googlegroups.com> <9322eedb3a632f5-29a98@gmail.com> <351fe53469ed0a6-fdb69@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 8bit Injection-Info: mx03.eternal-september.org; posting-host="UJ+SW6EYtZE9LcEeFRrivQ"; logging-data="25452"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/QYaiKDfFGduzZmiI5aAtd" User-Agent: nn 6.7.3 Content-Length: 3461 Cancel-Lock: sha1:Y+mxjc1iujd59XKMsFzvZoxxBE8= Xref: x330-a1.tempe.blueboxinc.net comp.lang.c:3979 On Sat, May 14, 2011 at 04:01:40PM -0400, James Kuyper wrote: > On 05/14/2011 03:10 PM, Uncle Steve wrote: > > On Sat, May 14, 2011 at 02:19:25PM -0400, Eric Sosman wrote: > >> On 5/14/2011 1:59 PM, Uncle Steve wrote: > >>> On Thu, May 12, 2011 at 06:53:02PM -0500, Shao Miller wrote: > >>>> On 5/12/2011 6:22 PM, Uncle Steve wrote: > >>>>> [...] I would like to declare: > >>>>> > >>>>> int foops[] = howmuchfoo(void); > >>>>> > >>>>> and have everything work as I expect... > >>>> [...] > >>>> > >>>> - In your code example, is howmuchfoo() supposed to be returning an > >>>> array of 'int' or a single 'int'? > >>> > >>> I don't see how that's relevant to the question. > >> > >> The point is that the one-line fragment you posted is not > >> valid C, not if `howmuchfoo(void)' is any kind of function at all. > > > > Yes, and I figured out that I had a misconception of how gcc handles > > non-constant initilizers. I've already admitted that I'm not coding > > anything specific at the moment, and instead /contemplating/ an > > approach to solving a particular problem, of which variable > > initialization is a part. > > > >> (If `howmuchfoo' is a function-like macro, it can of course expand > >> at compile-time into pretty much anything.) But if it's a function > >> call, the fragment is meaningless regardless of what scope it appears > >> in -- which means that by exhibiting it you have conveyed no meaning > >> to anyone. It is as if you had offered `int foops[] = !;' > >> and expected people to understand you. If you want to be understood, > >> you'll have to explain yourself more clearly. > > l > > I think that I'm being clear enough here. > > You think incorrectly. howmuchfoo() can't be a function call. It could *Now* I know it can't be a function call, but I didn't before. I thought I explained that already. > be a function-like macro, but if so, the possibilities are too > open-ended to be discussed in the abstract; we need information about > the nature of that macro before your question can be addressed. No, we need to consider things in the abstract so we may derive general principles. Is that too much to ask? > > ... The problem may be that > > the subtleties associated with these issues are difficult to > > articulate. If you don't like my humor, say so. > > It has nothing to do with your sense of humor. Heh, well that's good. > ... > >> Something that strikes me as odd is that you(?) started this > >> thread with the statement that you(?) sought a "maximally portable" > >> solution. Why, then, all this haring off after blatantly non- > >> portable approaches? Lost sight of the objective, or just trolling? > > > > I don't see where I've committed to any "blatantly" non-portable > > approaches. In actual point of fact I've been asking about certain > > compiler features and their actual prevalence in the field. > > By definition, compiler features mandated by the standard are available > on every single fully conforming implementation. Therefore, code which > relies on any feature that is less than universally prevalent (such as > zero-length arrays) is non-portable. I was just throwing that out there as an example. I don't really need zero-length arrays, but if they're available it looks cleaner to use them. Regards, Uncle Steve -- Should a professional politician be charged with molestation if he kisses babies while attending political rallies?