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: Thu, 12 May 2011 19:22:59 -0400 Organization: Friends of the Galactic Collective Lines: 34 Message-ID: References: <0ca8ca5b-e73e-418a-935f-0fcc17fdf404@q14g2000prh.googlegroups.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="27235"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+TrDMyMwp+HFZ0GH+Nr27G" User-Agent: nn 6.7.3 Content-Length: 1236 Cancel-Lock: sha1:wmhoMny7mF2YmQh6jKKEvBj7ne0= Xref: x330-a1.tempe.blueboxinc.net comp.lang.c:3865 On Thu, May 12, 2011 at 06:08:46PM -0500, Shao Miller wrote: > On 5/12/2011 5:59 PM, Fred the Freshwater Catfish wrote: > >...I'd like to use non-constant > >initializers for some global variables. I'm pretty sure I can get it > >to work the way I want under gcc, but what of other compilers? The > >gcc documentation in info format says that ISO C99 allows this, and so > >I expect some compilers built in the 90's will support the feature, > >but to what extent is this true? > > Could you please share an example of what kind of non-constant you'd be > inclined to initialize a static-duration, file-scoped object with? Are > you talking about using a function's return value? Are you talking > about using the address of something whose address you don't know at > some point in time? Essentially, I'm looking to seed a few critical global variables with run-time computed values. Obviously, this will be the product of a function call. I would like to declare: int foops[] = howmuchfoo(void); and have everything work as I expect. Pie in the sky for non-recent UN*Xes? Regards, Uncle Steve -- Should a professional politician be charged with molestation if he kisses babies while attending political rallies?