Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.arch > #1374 > unrolled thread
| Started by | George Neuner <gneuner2@comcast.net> |
|---|---|
| First post | 2011-05-07 03:06 -0400 |
| Last post | 2011-05-09 16:08 -0700 |
| Articles | 20 on this page of 124 — 27 participants |
Back to article view | Back to comp.arch
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: Computer arithmetic problems worth exploring George Neuner <gneuner2@comcast.net> - 2011-05-07 03:06 -0400
Re: Computer arithmetic problems worth exploring nmm1@cam.ac.uk - 2011-05-07 09:44 +0100
Re: Computer arithmetic problems worth exploring Tom Gardner <spamjunk@blueyonder.co.uk> - 2011-05-07 11:38 +0100
Re: Computer arithmetic problems worth exploring nmm1@cam.ac.uk - 2011-05-07 12:21 +0100
Re: Computer arithmetic problems worth exploring Tom Gardner <spamjunk@blueyonder.co.uk> - 2011-05-07 13:47 +0100
Re: Computer arithmetic problems worth exploring Quadibloc <jsavard@ecn.ab.ca> - 2011-05-07 09:55 -0700
Re: Computer arithmetic problems worth exploring Tom Gardner <spamjunk@blueyonder.co.uk> - 2011-05-07 19:27 +0100
Re: Computer arithmetic problems worth exploring Quadibloc <jsavard@ecn.ab.ca> - 2011-05-07 13:54 -0700
Re: Computer arithmetic problems worth exploring George Neuner <gneuner2@comcast.net> - 2011-05-09 13:38 -0400
Re: Computer arithmetic problems worth exploring Robert A Duff <bobduff@shell01.TheWorld.com> - 2011-05-10 12:40 -0400
Re: Computer arithmetic problems worth exploring Terje Mathisen <"terje.mathisen at tmsw.no"> - 2011-05-10 20:32 +0200
Re: Computer arithmetic problems worth exploring torbenm@diku.dk (Torben Ægidius Mogensen) - 2011-05-09 13:42 +0200
Re: Computer arithmetic problems worth exploring Quadibloc <jsavard@ecn.ab.ca> - 2011-05-07 04:26 -0700
Re: Computer arithmetic problems worth exploring nmm1@cam.ac.uk - 2011-05-07 12:13 +0100
Re: Computer arithmetic problems worth exploring "Andy \"Krazy\" Glew" <andy@SPAM.comp-arch.net> - 2011-05-07 14:59 -0700
Re: Computer arithmetic problems worth exploring George Neuner <gneuner2@comcast.net> - 2011-05-09 14:14 -0400
Re: Computer arithmetic problems worth exploring nmm1@cam.ac.uk - 2011-05-09 20:38 +0100
Re: Computer arithmetic problems worth exploring "Andy \"Krazy\" Glew" <andy@SPAM.comp-arch.net> - 2011-05-09 13:55 -0700
Re: Computer arithmetic problems worth exploring nmm1@cam.ac.uk - 2011-05-10 09:05 +0100
Re: Computer arithmetic problems worth exploring Jason Riedy <jason@lovesgoodfood.com> - 2011-05-10 13:24 -0400
Re: Computer arithmetic problems worth exploring nmm1@cam.ac.uk - 2011-05-10 18:41 +0100
Re: Computer arithmetic problems worth exploring "Andy \"Krazy\" Glew" <andy@SPAM.comp-arch.net> - 2011-05-11 13:56 -0700
Re: Computer arithmetic problems worth exploring "Andy \"Krazy\" Glew" <andy@SPAM.comp-arch.net> - 2011-05-11 14:04 -0700
Re: Computer arithmetic problems worth exploring "Andy \"Krazy\" Glew" <andy@SPAM.comp-arch.net> - 2011-05-11 14:06 -0700
Re: Computer arithmetic problems worth exploring "Andy \"Krazy\" Glew" <andy@SPAM.comp-arch.net> - 2011-05-11 13:55 -0700
Re: Computer arithmetic problems worth exploring nmm1@cam.ac.uk - 2011-05-11 22:15 +0100
Re: Computer arithmetic problems worth exploring Tom Gardner <spamjunk@blueyonder.co.uk> - 2011-05-12 20:52 +0100
Re: Computer arithmetic problems worth exploring nmm1@cam.ac.uk - 2011-05-12 20:20 +0100
Re: Computer arithmetic problems worth exploring Quadibloc <jsavard@ecn.ab.ca> - 2011-05-12 14:55 -0700
Re: Computer arithmetic problems worth exploring Terje Mathisen <"terje.mathisen at tmsw.no"> - 2011-05-13 12:25 +0200
Re: Computer arithmetic problems worth exploring nmm1@cam.ac.uk - 2011-05-13 11:18 +0100
Re: Computer arithmetic problems worth exploring "Andy \"Krazy\" Glew" <andy@SPAM.comp-arch.net> - 2011-05-14 13:19 -0700
Re: Computer arithmetic problems worth exploring Quadibloc <jsavard@ecn.ab.ca> - 2011-05-14 19:11 -0700
Re: Computer arithmetic problems worth exploring "Andy \"Krazy\" Glew" <andy@SPAM.comp-arch.net> - 2011-05-12 20:08 -0700
Re: Computer arithmetic problems worth exploring Jason Riedy <jason@lovesgoodfood.com> - 2011-05-12 23:54 -0400
Re: Computer arithmetic problems worth exploring George Neuner <gneuner2@comcast.net> - 2011-05-12 01:08 -0400
Re: Computer arithmetic problems worth exploring nmm1@cam.ac.uk - 2011-05-12 09:27 +0100
Re: Computer arithmetic problems worth exploring Quadibloc <jsavard@ecn.ab.ca> - 2011-05-12 05:41 -0700
Re: Computer arithmetic problems worth exploring nmm1@cam.ac.uk - 2011-05-12 13:22 +0100
Re: Computer arithmetic problems worth exploring Quadibloc <jsavard@ecn.ab.ca> - 2011-05-12 07:22 -0700
Re: Computer arithmetic problems worth exploring nmm1@cam.ac.uk - 2011-05-12 14:58 +0100
Re: Computer arithmetic problems worth exploring MitchAlsup <MitchAlsup@aol.com> - 2011-05-12 09:23 -0700
Non-constant initializers Fred the Freshwater Catfish <usenet.fred@bdtd.invalid> - 2011-05-12 22:59 +0000
Re: Non-constant initializers Ian Collins <ian-news@hotmail.com> - 2011-05-13 11:07 +1200
Re: Non-constant initializers Fred the Freshwater Catfish <usenet.fred@bdtd.invalid> - 2011-05-12 23:17 +0000
Re: Non-constant initializers Ian Collins <ian-news@hotmail.com> - 2011-05-13 11:20 +1200
Re: Non-constant initializers Fred the Freshwater Catfish <usenet.fred@bdtd.invalid> - 2011-05-12 23:30 +0000
Re: Non-constant initializers Ian Collins <ian-news@hotmail.com> - 2011-05-13 11:34 +1200
Re: Non-constant initializers Keith Thompson <kst-u@mib.org> - 2011-05-12 16:52 -0700
Re: Non-constant initializers Fred the Freshwater Catfish <usenet.fred@bdtd.invalid> - 2011-05-14 00:13 +0000
Re: Non-constant initializers kym@kymhorsell.com - 2011-05-14 01:54 +0000
Re: Non-constant initializers Columbus sailed the ocean China Blue <chine.bleu@yahoo.com> - 2011-05-14 01:07 -0700
Re: Non-constant initializers kym@kymhorsell.com - 2011-05-14 09:22 +0000
Re: Non-constant initializers Fred the Freshwater Catfish <usenet.fred@bdtd.invalid> - 2011-05-14 17:14 +0000
Re: Non-constant initializers Fred the Freshwater Catfish <usenet.fred@bdtd.invalid> - 2011-05-14 00:11 +0000
Re: Non-constant initializers Columbus sailed the ocean China Blue <chine.bleu@yahoo.com> - 2011-05-12 16:15 -0700
Re: Non-constant initializers Fred the Freshwater Catfish <usenet.fred@bdtd.invalid> - 2011-05-12 23:28 +0000
Re: Non-constant initializers Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2011-05-12 18:01 -0600
Re: Non-constant initializers Keith Thompson <kst-u@mib.org> - 2011-05-12 18:15 -0700
Re: Non-constant initializers Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2011-05-12 22:56 -0600
Re: Non-constant initializers Seebs <usenet-nospam@seebs.net> - 2011-05-13 05:18 +0000
Re: Non-constant initializers Fred the Freshwater Catfish <usenet.fred@bdtd.invalid> - 2011-05-13 23:57 +0000
Re: Computer arithmetic problems worth exploring "Andy \"Krazy\" Glew" <andy@SPAM.comp-arch.net> - 2011-05-12 20:20 -0700
Re: Computer arithmetic problems worth exploring nmm1@cam.ac.uk - 2011-05-13 09:48 +0100
Re: Computer arithmetic problems worth exploring Terje Mathisen <"terje.mathisen at tmsw.no"> - 2011-05-13 12:55 +0200
Re: Computer arithmetic problems worth exploring nmm1@cam.ac.uk - 2011-05-13 11:25 +0100
Re: Computer arithmetic problems worth exploring MitchAlsup <MitchAlsup@aol.com> - 2011-05-13 08:57 -0700
Re: Computer arithmetic problems worth exploring nmm1@cam.ac.uk - 2011-05-13 16:42 +0100
Re: Computer arithmetic problems worth exploring MitchAlsup <MitchAlsup@aol.com> - 2011-05-13 13:17 -0700
Re: Computer arithmetic problems worth exploring nmm1@cam.ac.uk - 2011-05-13 21:03 +0100
Re: Computer arithmetic problems worth exploring Terje Mathisen <"terje.mathisen at tmsw.no"> - 2011-05-14 06:43 +0200
Re: Computer arithmetic problems worth exploring Tom Gardner <spamjunk@blueyonder.co.uk> - 2011-05-14 06:55 +0100
Re: Computer arithmetic problems worth exploring "Ken Hagan" <k.hagan@thermoteknix.com> - 2011-05-17 12:59 +0100
Re: Computer arithmetic problems worth exploring nmm1@cam.ac.uk - 2011-05-17 12:44 +0100
Re: Computer arithmetic problems worth exploring Tom Gardner <spamjunk@blueyonder.co.uk> - 2011-05-17 14:07 +0100
Re: Computer arithmetic problems worth exploring nmm1@cam.ac.uk - 2011-05-17 17:20 +0100
Re: Computer arithmetic problems worth exploring "Ken Hagan" <k.hagan@thermoteknix.com> - 2011-05-17 15:03 +0100
Re: Computer arithmetic problems worth exploring nmm1@cam.ac.uk - 2011-05-14 08:43 +0100
Re: Computer arithmetic problems worth exploring nmm1@cam.ac.uk - 2011-05-14 09:17 +0100
Re: Computer arithmetic problems worth exploring Stephen Fuld <SFuld@alumni.cmu.edu.invalid> - 2011-05-14 09:04 -0700
Re: Computer arithmetic problems worth exploring "Andy \"Krazy\" Glew" <andy@SPAM.comp-arch.net> - 2011-05-14 17:00 -0700
Re: Computer arithmetic problems worth exploring "Andy \"Krazy\" Glew" <andy@SPAM.comp-arch.net> - 2011-05-14 16:58 -0700
Re: Computer arithmetic problems worth exploring Quadibloc <jsavard@ecn.ab.ca> - 2011-05-14 19:07 -0700
Re: Computer arithmetic problems worth exploring nmm1@cam.ac.uk - 2011-05-15 09:40 +0100
Re: Computer arithmetic problems worth exploring Terje Mathisen <"terje.mathisen at tmsw.no"> - 2011-05-16 11:05 +0200
Re: Computer arithmetic problems worth exploring Quadibloc <jsavard@ecn.ab.ca> - 2011-05-16 06:44 -0700
Re: Computer arithmetic problems worth exploring mac <acolvin@efunct.com> - 2011-05-19 20:17 +0000
Re: Computer arithmetic problems worth exploring Quadibloc <jsavard@ecn.ab.ca> - 2011-05-19 15:20 -0700
Re: Computer arithmetic problems worth exploring George Neuner <gneuner2@comcast.net> - 2011-05-19 18:51 -0400
Re: Computer arithmetic problems worth exploring Petter Gustad <newsmailcomp6@gustad.com> - 2011-05-20 08:01 +0200
Re: Computer arithmetic problems worth exploring "Andy \"Krazy\" Glew" <andy@SPAM.comp-arch.net> - 2011-05-20 15:09 -0700
Re: Computer arithmetic problems worth exploring Terje Mathisen <"terje.mathisen at tmsw.no"> - 2011-05-20 08:54 +0200
Re: Computer arithmetic problems worth exploring "Ken Hagan" <k.hagan@thermoteknix.com> - 2011-05-23 11:11 +0100
Re: Computer arithmetic problems worth exploring George Neuner <gneuner2@comcast.net> - 2011-05-23 18:20 -0400
Re: Computer arithmetic problems worth exploring Morten Reistad <first@last.name> - 2011-06-03 08:21 +0200
Re: Computer arithmetic problems worth exploring Stephen Fuld <SFuld@alumni.cmu.edu.invalid> - 2011-05-19 13:31 -0700
Re: Computer arithmetic problems worth exploring Stephen Fuld <SFuld@alumni.cmu.edu.invalid> - 2011-05-16 09:05 -0700
Re: Computer arithmetic problems worth exploring Terje Mathisen <"terje.mathisen at tmsw.no"> - 2011-05-16 22:37 +0200
Re: Computer arithmetic problems worth exploring Stephen Fuld <SFuld@alumni.cmu.edu.invalid> - 2011-05-18 23:16 -0700
Re: Computer arithmetic problems worth exploring ChrisQ <meru@devnull.com> - 2011-05-17 17:10 +0100
Re: Computer arithmetic problems worth exploring Tom Gardner <spamjunk@blueyonder.co.uk> - 2011-05-17 17:27 +0100
Re: Computer arithmetic problems worth exploring ChrisQ <meru@devnull.com> - 2011-05-17 23:08 +0100
Re: Computer arithmetic problems worth exploring Tom <tggzzz@blueyonder.co.uk> - 2011-05-17 22:37 +0000
Re: Computer arithmetic problems worth exploring nmm1@cam.ac.uk - 2011-05-18 09:25 +0100
Re: Computer arithmetic problems worth exploring Quadibloc <jsavard@ecn.ab.ca> - 2011-05-18 06:25 -0700
Re: Computer arithmetic problems worth exploring nmm1@cam.ac.uk - 2011-05-18 14:06 +0100
Re: Computer arithmetic problems worth exploring Tom Gardner <spamjunk@blueyonder.co.uk> - 2011-05-18 19:23 +0100
Re: Computer arithmetic problems worth exploring Quadibloc <jsavard@ecn.ab.ca> - 2011-05-18 13:48 -0700
Re: Computer arithmetic problems worth exploring Andrew Reilly <areilly---@bigpond.net.au> - 2011-05-19 00:29 +0000
Re: Computer arithmetic problems worth exploring "Ken Hagan" <k.hagan@thermoteknix.com> - 2011-05-19 13:12 +0100
Re: Computer arithmetic problems worth exploring Stephen Fuld <SFuld@alumni.cmu.edu.invalid> - 2011-05-18 23:27 -0700
Re: Computer arithmetic problems worth exploring Quadibloc <jsavard@ecn.ab.ca> - 2011-05-19 15:19 -0700
Re: Computer arithmetic problems worth exploring Stephen Fuld <SFuld@alumni.cmu.edu.invalid> - 2011-05-20 07:33 -0700
Re: Computer arithmetic problems worth exploring Michael S <already5chosen@yahoo.com> - 2011-05-16 03:14 -0700
Re: Computer arithmetic problems worth exploring nmm1@cam.ac.uk - 2011-05-16 10:43 +0100
Re: Computer arithmetic problems worth exploring Michael S <already5chosen@yahoo.com> - 2011-05-16 04:58 -0700
Re: Computer arithmetic problems worth exploring nmm1@cam.ac.uk - 2011-05-16 12:40 +0100
Re: Computer arithmetic problems worth exploring MitchAlsup <MitchAlsup@aol.com> - 2011-05-15 10:12 -0700
Re: Computer arithmetic problems worth exploring "Andy \"Krazy\" Glew" <andy@SPAM.comp-arch.net> - 2011-05-14 13:22 -0700
Re: Computer arithmetic problems worth exploring nmm1@cam.ac.uk - 2011-05-15 09:02 +0100
Re: Computer arithmetic problems worth exploring "Andy \"Krazy\" Glew" <andy@SPAM.comp-arch.net> - 2011-05-14 14:02 -0700
Re: Computer arithmetic problems worth exploring "Andy \"Krazy\" Glew" <andy@SPAM.comp-arch.net> - 2011-05-12 20:18 -0700
Re: Computer arithmetic problems worth exploring Robert Myers <rbmyersusa@gmail.com> - 2011-05-09 14:32 -0700
Re: Computer arithmetic problems worth exploring "Andy \"Krazy\" Glew" <andy@SPAM.comp-arch.net> - 2011-05-09 16:08 -0700
Page 3 of 7 — ← Prev page 1 2 [3] 4 5 6 7 Next page →
| From | nmm1@cam.ac.uk |
|---|---|
| Date | 2011-05-12 14:58 +0100 |
| Message-ID | <iqgp2j$h9h$1@gosset.csi.cam.ac.uk> |
| In reply to | #1493 |
In article <0ca8ca5b-e73e-418a-935f-0fcc17fdf404@q14g2000prh.googlegroups.com>, Quadibloc <jsavard@ecn.ab.ca> wrote: > >> There were a lot of examples in the 1970s of how a hexadecimal >> base could cause an error build up of that magnitude per step, >> but almost all were bogus as they took truncation as a basic >> assumption! > >Of course, IBM System/360 floating-point *did* truncate instead of >round. That simplified implementation of the low-end machines by >increasing the commonalities between fixed-point arithmetic and >floating-point arithmetic. Quite. And its justified reputation for poor accuracy was due to that, almost entirely. >I do agree with you, though, that superfluous precision, except for >wasting storage space and computation time, is not intrinsically >harmful, even if that precision is present or absent in a capricious >manner - when the rounding, and the variation in precision are both >unbiased. Even the latter is fairly minor. I have used twos' complement, rounded to nearest, floating-point, and that was fine. Regards, Nick Maclaren.
[toc] | [prev] | [next] | [standalone]
| From | MitchAlsup <MitchAlsup@aol.com> |
|---|---|
| Date | 2011-05-12 09:23 -0700 |
| Message-ID | <6bd1a928-11de-4d08-a4eb-35fad93f192e@d27g2000vbz.googlegroups.com> |
| In reply to | #1494 |
On May 12, 8:58 am, n...@cam.ac.uk wrote: > In article <0ca8ca5b-e73e-418a-935f-0fcc17fdf...@q14g2000prh.googlegroups.com>, > > Quadibloc <jsav...@ecn.ab.ca> wrote: > > >> There were a lot of examples in the 1970s of how a hexadecimal > >> base could cause an error build up of that magnitude per step, > >> but almost all were bogus as they took truncation as a basic > >> assumption! > > >Of course, IBM System/360 floating-point *did* truncate instead of > >round. That simplified implementation of the low-end machines by > >increasing the commonalities between fixed-point arithmetic and > >floating-point arithmetic. > > Quite. And its justified reputation for poor accuracy was due to > that, almost entirely. That, and the fact that the first System/360 implementations did not compute with a guard digit prior to truncation (which was quickly and quietly fixed.) Mitch
[toc] | [prev] | [next] | [standalone]
| From | Fred the Freshwater Catfish <usenet.fred@bdtd.invalid> |
|---|---|
| Date | 2011-05-12 22:59 +0000 |
| Subject | Non-constant initializers |
| Message-ID | <OgcdY5.Lcq.Cst0A@btdt.invalid> |
| In reply to | #1494 |
Hey guys, I've been writing some code that I would prefer to be maximally portable. As I have mostly used Linux, gcc is pretty much the only C compiler I've ever used under UN*X. 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? What I mean to learn is the general prevalence of this C feature. If there's no support for certain well-known platforms (maybe SunOS or OSF/1, whatever) I may consider a different solution to the original problem, but I'd like to know what I'm getting in to before I start trying to read the docs for every bloody C compiler that ever hit the 'net in the last twenty years. Thanks if you can shed any light on this subject. Fred the Freshwater Catfish
[toc] | [prev] | [next] | [standalone]
| From | Ian Collins <ian-news@hotmail.com> |
|---|---|
| Date | 2011-05-13 11:07 +1200 |
| Subject | Re: Non-constant initializers |
| Message-ID | <9337gtFoqoU4@mid.individual.net> |
| In reply to | #1502 |
On 05/13/11 10:59 AM, Fred the Freshwater Catfish wrote: > Hey guys, > > I've been writing some code that I would prefer to be maximally > portable. As I have mostly used Linux, gcc is pretty much the only C > compiler I've ever used under UN*X. 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? How do you derive the initialiser values? -- Ian Collins
[toc] | [prev] | [next] | [standalone]
| From | Fred the Freshwater Catfish <usenet.fred@bdtd.invalid> |
|---|---|
| Date | 2011-05-12 23:17 +0000 |
| Subject | Re: Non-constant initializers |
| Message-ID | <2u43Sw.GXK.PAfQI@btdt.invalid> |
| In reply to | #1503 |
On Fri, May 13, 2011 at 11:07:09AM +1200, Ian Collins wrote: > On 05/13/11 10:59 AM, Fred the Freshwater Catfish wrote: > >Hey guys, > > > >I've been writing some code that I would prefer to be maximally > >portable. As I have mostly used Linux, gcc is pretty much the only C > >compiler I've ever used under UN*X. 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? > > How do you derive the initialiser values? It should end up being a function call most of the time. Fred the Freshwater Catfish
[toc] | [prev] | [next] | [standalone]
| From | Ian Collins <ian-news@hotmail.com> |
|---|---|
| Date | 2011-05-13 11:20 +1200 |
| Subject | Re: Non-constant initializers |
| Message-ID | <93389uFoqoU5@mid.individual.net> |
| In reply to | #1505 |
On 05/13/11 11:17 AM, Fred the Freshwater Catfish wrote: > On Fri, May 13, 2011 at 11:07:09AM +1200, Ian Collins wrote: >> On 05/13/11 10:59 AM, Fred the Freshwater Catfish wrote: >>> Hey guys, >>> >>> I've been writing some code that I would prefer to be maximally >>> portable. As I have mostly used Linux, gcc is pretty much the only C >>> compiler I've ever used under UN*X. 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? >> >> How do you derive the initialiser values? > > It should end up being a function call most of the time. Then you either want C++, or a singleton fiddle as posted else-thread. -- Ian Collins
[toc] | [prev] | [next] | [standalone]
| From | Fred the Freshwater Catfish <usenet.fred@bdtd.invalid> |
|---|---|
| Date | 2011-05-12 23:30 +0000 |
| Subject | Re: Non-constant initializers |
| Message-ID | <PKQM7h.2nC.DM4ea@btdt.invalid> |
| In reply to | #1506 |
On Fri, May 13, 2011 at 11:20:30AM +1200, Ian Collins wrote: > On 05/13/11 11:17 AM, Fred the Freshwater Catfish wrote: > >On Fri, May 13, 2011 at 11:07:09AM +1200, Ian Collins wrote: > >>On 05/13/11 10:59 AM, Fred the Freshwater Catfish wrote: > >>>Hey guys, > >>> > >>>I've been writing some code that I would prefer to be maximally > >>>portable. As I have mostly used Linux, gcc is pretty much the only C > >>>compiler I've ever used under UN*X. 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? > >> > >>How do you derive the initialiser values? > > > >It should end up being a function call most of the time. > > Then you either want C++, or a singleton fiddle as posted else-thread. Sorry, I'm not using C++. Fred the Freshwater Catfish
[toc] | [prev] | [next] | [standalone]
| From | Ian Collins <ian-news@hotmail.com> |
|---|---|
| Date | 2011-05-13 11:34 +1200 |
| Subject | Re: Non-constant initializers |
| Message-ID | <93393vFoqoU6@mid.individual.net> |
| In reply to | #1508 |
On 05/13/11 11:30 AM, Fred the Freshwater Catfish wrote: > On Fri, May 13, 2011 at 11:20:30AM +1200, Ian Collins wrote: >> On 05/13/11 11:17 AM, Fred the Freshwater Catfish wrote: >>> On Fri, May 13, 2011 at 11:07:09AM +1200, Ian Collins wrote: >>>> On 05/13/11 10:59 AM, Fred the Freshwater Catfish wrote: >>>>> Hey guys, >>>>> >>>>> I've been writing some code that I would prefer to be maximally >>>>> portable. As I have mostly used Linux, gcc is pretty much the only C >>>>> compiler I've ever used under UN*X. 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? >>>> >>>> How do you derive the initialiser values? >>> >>> It should end up being a function call most of the time. >> >> Then you either want C++, or a singleton fiddle as posted else-thread. > > Sorry, I'm not using C++. But you require a C++ feature... You could compile all but main() as C and compile the source file containing main() and your initialisers as C++. -- Ian Collins
[toc] | [prev] | [next] | [standalone]
| From | Keith Thompson <kst-u@mib.org> |
|---|---|
| Date | 2011-05-12 16:52 -0700 |
| Subject | Re: Non-constant initializers |
| Message-ID | <lniptfiiic.fsf@nuthaus.mib.org> |
| In reply to | #1509 |
Ian Collins <ian-news@hotmail.com> writes:
> On 05/13/11 11:30 AM, Fred the Freshwater Catfish wrote:
>> On Fri, May 13, 2011 at 11:20:30AM +1200, Ian Collins wrote:
>>> On 05/13/11 11:17 AM, Fred the Freshwater Catfish wrote:
>>>> On Fri, May 13, 2011 at 11:07:09AM +1200, Ian Collins wrote:
>>>>> On 05/13/11 10:59 AM, Fred the Freshwater Catfish wrote:
>>>>>> Hey guys,
>>>>>>
>>>>>> I've been writing some code that I would prefer to be maximally
>>>>>> portable. As I have mostly used Linux, gcc is pretty much the only C
>>>>>> compiler I've ever used under UN*X. 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?
>>>>>
>>>>> How do you derive the initialiser values?
>>>>
>>>> It should end up being a function call most of the time.
>>>
>>> Then you either want C++, or a singleton fiddle as posted else-thread.
>>
>> Sorry, I'm not using C++.
>
> But you require a C++ feature...
>
> You could compile all but main() as C and compile the source file
> containing main() and your initialisers as C++.
Or, rather than using a non-constant initializer, you can call a routine
from main() that initialize the objects.
--
Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
[toc] | [prev] | [next] | [standalone]
| From | Fred the Freshwater Catfish <usenet.fred@bdtd.invalid> |
|---|---|
| Date | 2011-05-14 00:13 +0000 |
| Subject | Re: Non-constant initializers |
| Message-ID | <yemBS9.FUV.7wkYM@btdt.invalid> |
| In reply to | #1510 |
On Thu, May 12, 2011 at 04:52:43PM -0700, Keith Thompson wrote: > Ian Collins <ian-news@hotmail.com> writes: > > On 05/13/11 11:30 AM, Fred the Freshwater Catfish wrote: > >> On Fri, May 13, 2011 at 11:20:30AM +1200, Ian Collins wrote: > >>> On 05/13/11 11:17 AM, Fred the Freshwater Catfish wrote: > >>>> On Fri, May 13, 2011 at 11:07:09AM +1200, Ian Collins wrote: > >>>>> On 05/13/11 10:59 AM, Fred the Freshwater Catfish wrote: > >>>>>> Hey guys, > >>>>>> > >>>>>> I've been writing some code that I would prefer to be maximally > >>>>>> portable. As I have mostly used Linux, gcc is pretty much the only C > >>>>>> compiler I've ever used under UN*X. 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? > >>>>> > >>>>> How do you derive the initialiser values? > >>>> > >>>> It should end up being a function call most of the time. > >>> > >>> Then you either want C++, or a singleton fiddle as posted else-thread. > >> > >> Sorry, I'm not using C++. > > > > But you require a C++ feature... > > > > You could compile all but main() as C and compile the source file > > containing main() and your initialisers as C++. > > Or, rather than using a non-constant initializer, you can call a routine > from main() that initialize the objects. That's a pretty good idea, but I was looking for something convenient to set-up global-scope variables in a library. No big deal, but I thought I could be clever about it. Fred the Freshwater Catfish
[toc] | [prev] | [next] | [standalone]
| From | kym@kymhorsell.com |
|---|---|
| Date | 2011-05-14 01:54 +0000 |
| Subject | Re: Non-constant initializers |
| Message-ID | <4dcde0cd$0$24911$afc38c87@news.optusnet.com.au> |
| In reply to | #1556 |
In comp.arch Fred the Freshwater Catfish <usenet.fred@bdtd.invalid> wrote: ... > That's a pretty good idea, but I was looking for something convenient > to set-up global-scope variables in a library. No big deal, but I > thought I could be clever about it. On some platforms its the linker that's responsible for once-only runtime initialisations. If you name a routine in a special way, or make sure it's in a code segment with a special name, the linker sets up code to ensure the code gets called before main(). No need for static "has it been done yet" variables or explicit calls. This is how gnu C++ compilers typically arrange for global initialisations. Unlike the idea of calling C++ from C (which usually won't work), just hanging off this hook generally does work -- if you can find the documentation. -- If there was no warming or cooling trend, then the chance of 2007 being tied with 1998 [130 year record!] would be quite high. -- No Pressure <no.pressure.at.all@gmail.com>, 11 Dec 2010 05:20:39 -0800
[toc] | [prev] | [next] | [standalone]
| From | Columbus sailed the ocean China Blue <chine.bleu@yahoo.com> |
|---|---|
| Date | 2011-05-14 01:07 -0700 |
| Subject | Re: Non-constant initializers |
| Message-ID | <chine.bleu-5E3613.01071714052011@reserved-multicast-range-not-delegated.example.com> |
| In reply to | #1558 |
In article <4dcde0cd$0$24911$afc38c87@news.optusnet.com.au>, kym@kymhorsell.com wrote: > In comp.arch Fred the Freshwater Catfish <usenet.fred@bdtd.invalid> wrote: > ... > > That's a pretty good idea, but I was looking for something convenient > > to set-up global-scope variables in a library. No big deal, but I > > thought I could be clever about it. > > On some platforms its the linker that's responsible for once-only > runtime initialisations. If you name a routine in a special way, > or make sure it's in a code segment with a special name, the linker > sets up code to ensure the code gets called before main(). No need > for static "has it been done yet" variables or explicit calls. > > This is how gnu C++ compilers typically arrange for global initialisations. > > Unlike the idea of calling C++ from C (which usually won't work), just > hanging off this hook generally does work -- if you can find the > documentation. Unfortunately this solution is not guarenteed to be available on all platforms. -- Damn the living - It's a lovely life. I'm whoever you want me to be. Silver silverware - Where is the love? At least I can stay in character. Oval swimming pool - Where is the love? Annoying Usenet one post at a time. Damn the living - It's a lovely life. In 1492....
[toc] | [prev] | [next] | [standalone]
| From | kym@kymhorsell.com |
|---|---|
| Date | 2011-05-14 09:22 +0000 |
| Subject | Re: Non-constant initializers |
| Message-ID | <4dce49d3$0$13390$afc38c87@news.optusnet.com.au> |
| In reply to | #1561 |
In comp.arch Columbus sailed the ocean China Blue <chine.bleu@yahoo.com> wrote: > In article <4dcde0cd$0$24911$afc38c87@news.optusnet.com.au>, kym@kymhorsell.com > wrote: >> In comp.arch Fred the Freshwater Catfish <usenet.fred@bdtd.invalid> wrote: >> ... >> > That's a pretty good idea, but I was looking for something convenient >> > to set-up global-scope variables in a library. No big deal, but I >> > thought I could be clever about it. >> On some platforms its the linker that's responsible for once-only >> runtime initialisations. If you name a routine in a special way, >> or make sure it's in a code segment with a special name, the linker >> sets up code to ensure the code gets called before main(). No need >> for static "has it been done yet" variables or explicit calls. >> This is how gnu C++ compilers typically arrange for global initialisations. >> Unlike the idea of calling C++ from C (which usually won't work), just >> hanging off this hook generally does work -- if you can find the >> documentation. > Unfortunately this solution is not guarenteed to be available on all platforms. That's the agreed meaning of "on some platforms", yes. --- Scientists are always changing their story and as a Conservative, I have no tolerance for ambiguity. It proves that all science is lies and the only thing we can trust is right wing rhetoric. -- BONZO@27-32-240-172 [86 nyms and counting], 14 Jan 2011 14:46 +1100 CORRECTION: True science, (remember that?) can be trusted, but this "science" is ALL LIES! -- BONZO@27-32-240-172 [86 nyms and counting], 19 Feb 2011 14:46 +1100
[toc] | [prev] | [next] | [standalone]
| From | Fred the Freshwater Catfish <usenet.fred@bdtd.invalid> |
|---|---|
| Date | 2011-05-14 17:14 +0000 |
| Subject | Re: Non-constant initializers |
| Message-ID | <s0IQvN.Gi2.VZav4@btdt.invalid> |
| In reply to | #1565 |
On Sat, May 14, 2011 at 09:22:27AM +0000, kym@kymhorsell.com wrote: > In comp.arch Columbus sailed the ocean China Blue <chine.bleu@yahoo.com> wrote: > > In article <4dcde0cd$0$24911$afc38c87@news.optusnet.com.au>, kym@kymhorsell.com > > wrote: > >> In comp.arch Fred the Freshwater Catfish <usenet.fred@bdtd.invalid> wrote: > >> ... > >> > That's a pretty good idea, but I was looking for something convenient > >> > to set-up global-scope variables in a library. No big deal, but I > >> > thought I could be clever about it. > >> On some platforms its the linker that's responsible for once-only > >> runtime initialisations. If you name a routine in a special way, > >> or make sure it's in a code segment with a special name, the linker > >> sets up code to ensure the code gets called before main(). No need > >> for static "has it been done yet" variables or explicit calls. > >> This is how gnu C++ compilers typically arrange for global initialisations. > >> Unlike the idea of calling C++ from C (which usually won't work), just > >> hanging off this hook generally does work -- if you can find the > >> documentation. > > Unfortunately this solution is not guaranteed to be available on all platforms. > > That's the agreed meaning of "on some platforms", yes. Yeah. I know gcc supports constructor and destructor function attributes, with some sort of "priority" ranking, but I haven't fooled with it enough to make it work. I don't know how other compilers fare in this respect, but it seems like the kind feature that gets implemented differently by each compiler. I might end up using zero-length arrays in structure definitions if I find it's popular enough, but I'm really trying not to make my application require weird stuff just to compile, or in fact to tie my application to gcc. Fred the Freshwater Catfish
[toc] | [prev] | [next] | [standalone]
| From | Fred the Freshwater Catfish <usenet.fred@bdtd.invalid> |
|---|---|
| Date | 2011-05-14 00:11 +0000 |
| Subject | Re: Non-constant initializers |
| Message-ID | <VE0BgN.NVa.keJdC@btdt.invalid> |
| In reply to | #1509 |
On Fri, May 13, 2011 at 11:34:23AM +1200, Ian Collins wrote: > On 05/13/11 11:30 AM, Fred the Freshwater Catfish wrote: > >On Fri, May 13, 2011 at 11:20:30AM +1200, Ian Collins wrote: > >>On 05/13/11 11:17 AM, Fred the Freshwater Catfish wrote: > >>>On Fri, May 13, 2011 at 11:07:09AM +1200, Ian Collins wrote: > >>>>On 05/13/11 10:59 AM, Fred the Freshwater Catfish wrote: > >>>>>Hey guys, > >>>>> > >>>>>I've been writing some code that I would prefer to be maximally > >>>>>portable. As I have mostly used Linux, gcc is pretty much the only C > >>>>>compiler I've ever used under UN*X. 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? > >>>> > >>>>How do you derive the initialiser values? > >>> > >>>It should end up being a function call most of the time. > >> > >>Then you either want C++, or a singleton fiddle as posted else-thread. > > > >Sorry, I'm not using C++. > > But you require a C++ feature... > > You could compile all but main() as C and compile the source file > containing main() and your initialisers as C++. I guess, but then my code would be tainted by C++. I'd rather avoid requiring C++ in the build toolchain to compile the software. Fred the Freshwater Catfish
[toc] | [prev] | [next] | [standalone]
| From | Columbus sailed the ocean China Blue <chine.bleu@yahoo.com> |
|---|---|
| Date | 2011-05-12 16:15 -0700 |
| Subject | Re: Non-constant initializers |
| Message-ID | <chine.bleu-C88A78.16153612052011@reserved-multicast-range-not-delegated.example.com> |
| In reply to | #1502 |
In article <OgcdY5.Lcq.Cst0A@btdt.invalid>,
Fred the Freshwater Catfish <usenet.fred@bdtd.invalid> wrote:
> Hey guys,
>
> I've been writing some code that I would prefer to be maximally
> portable. As I have mostly used Linux, gcc is pretty much the only C
> compiler I've ever used under UN*X. 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?
>
> What I mean to learn is the general prevalence of this C feature. If
> there's no support for certain well-known platforms (maybe SunOS or
> OSF/1, whatever) I may consider a different solution to the original
> problem, but I'd like to know what I'm getting in to before I start
> trying to read the docs for every bloody C compiler that ever hit the
> 'net in the last twenty years.
I use an alternative strategy: if I want to implement
static double XYZ = nonconstant-expression;
I instead do
#define XYZ (*XYZ_())
static double *XYZ_(void) {
static double xyz;
static bool initialised = false;
LOCK
if (!initialised) {
xyz = nonconstant-expression;
initialised = true;
}
UNLOCK
return &xyz;
}
XYZ will be an lvalue just like any other variable; it gets initialised on the
first use; the initialisation can be any complicated as desired, using any
dependencies desired, without depending on the compiler and loader to sneak in
the initialisation code in the right order.
--
Damn the living - It's a lovely life. I'm whoever you want me to be.
Silver silverware - Where is the love? At least I can stay in character.
Oval swimming pool - Where is the love? Annoying Usenet one post at a time.
Damn the living - It's a lovely life. In 1492....
[toc] | [prev] | [next] | [standalone]
| From | Fred the Freshwater Catfish <usenet.fred@bdtd.invalid> |
|---|---|
| Date | 2011-05-12 23:28 +0000 |
| Subject | Re: Non-constant initializers |
| Message-ID | <i1u9RB.8qd.j2hEc@btdt.invalid> |
| In reply to | #1504 |
On Thu, May 12, 2011 at 04:15:36PM -0700, Columbus sailed the ocean China Blue wrote:
> In article <OgcdY5.Lcq.Cst0A@btdt.invalid>,
> Fred the Freshwater Catfish <usenet.fred@bdtd.invalid> wrote:
>
> > Hey guys,
> >
> > I've been writing some code that I would prefer to be maximally
> > portable. As I have mostly used Linux, gcc is pretty much the only C
> > compiler I've ever used under UN*X. 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?
> >
> > What I mean to learn is the general prevalence of this C feature. If
> > there's no support for certain well-known platforms (maybe SunOS or
> > OSF/1, whatever) I may consider a different solution to the original
> > problem, but I'd like to know what I'm getting in to before I start
> > trying to read the docs for every bloody C compiler that ever hit the
> > 'net in the last twenty years.
>
> I use an alternative strategy: if I want to implement
> static double XYZ = nonconstant-expression;
>
> I instead do
> #define XYZ (*XYZ_())
> static double *XYZ_(void) {
> static double xyz;
> static bool initialised = false;
> LOCK
> if (!initialised) {
> xyz = nonconstant-expression;
> initialised = true;
> }
> UNLOCK
> return &xyz;
> }
>
> XYZ will be an lvalue just like any other variable; it gets initialised on the
> first use; the initialisation can be any complicated as desired, using any
> dependencies desired, without depending on the compiler and loader to sneak in
> the initialisation code in the right order.
Hey, is that how you ancients did things in the 80's era? I hope
there's a better way.
Fred the Freshwater Catfish
[toc] | [prev] | [next] | [standalone]
| From | Joe Pfeiffer <pfeiffer@cs.nmsu.edu> |
|---|---|
| Date | 2011-05-12 18:01 -0600 |
| Subject | Re: Non-constant initializers |
| Message-ID | <1boc37h3il.fsf@snowball.wb.pfeifferfamily.net> |
| In reply to | #1502 |
Fred the Freshwater Catfish <usenet.fred@bdtd.invalid> writes: > > I've been writing some code that I would prefer to be maximally > portable. As I have mostly used Linux, gcc is pretty much the only C > compiler I've ever used under UN*X. 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? Where does the documentation say this is allowed by C99? The C99 standard says All the expressions in an initializer for an object that has static storage duration shall be constant expressions or string literals. (Section 6.7.8 paragraph 4) -- "It used to be that the USA was pretty good at producing stuff teenaged boys could lose a finger or two playing with." -- James Nicoll
[toc] | [prev] | [next] | [standalone]
| From | Keith Thompson <kst-u@mib.org> |
|---|---|
| Date | 2011-05-12 18:15 -0700 |
| Subject | Re: Non-constant initializers |
| Message-ID | <lnei43ienr.fsf@nuthaus.mib.org> |
| In reply to | #1511 |
Joe Pfeiffer <pfeiffer@cs.nmsu.edu> writes:
> Fred the Freshwater Catfish <usenet.fred@bdtd.invalid> writes:
>> I've been writing some code that I would prefer to be maximally
>> portable. As I have mostly used Linux, gcc is pretty much the only C
>> compiler I've ever used under UN*X. 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?
>
> Where does the documentation say this is allowed by C99? The C99
> standard says
>
> All the expressions in an initializer for an object that has static
> storage duration shall be constant expressions or string literals.
>
> (Section 6.7.8 paragraph 4)
I think this is the relevant section of the gcc document:
6.23 Non-Constant Initializers
==============================
As in standard C++ and ISO C99, the elements of an aggregate
initializer for an automatic variable are not required to
be constant expressions in GNU C. Here is an example of an
initializer with run-time varying elements:
foo (float f, float g)
{
float beat_freqs[2] = { f-g, f+g };
/* ... */
}
C90 requires constant expression for all initializers. C99 permits
non-constant expressions, but only for automatic variables.
--
Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
[toc] | [prev] | [next] | [standalone]
| From | Joe Pfeiffer <pfeiffer@cs.nmsu.edu> |
|---|---|
| Date | 2011-05-12 22:56 -0600 |
| Subject | Re: Non-constant initializers |
| Message-ID | <1b1v03jj0h.fsf@snowball.wb.pfeifferfamily.net> |
| In reply to | #1513 |
Keith Thompson <kst-u@mib.org> writes:
> Joe Pfeiffer <pfeiffer@cs.nmsu.edu> writes:
>> Fred the Freshwater Catfish <usenet.fred@bdtd.invalid> writes:
>>> I've been writing some code that I would prefer to be maximally
>>> portable. As I have mostly used Linux, gcc is pretty much the only C
>>> compiler I've ever used under UN*X. 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?
>>
>> Where does the documentation say this is allowed by C99? The C99
>> standard says
>>
>> All the expressions in an initializer for an object that has static
>> storage duration shall be constant expressions or string literals.
>>
>> (Section 6.7.8 paragraph 4)
>
> I think this is the relevant section of the gcc document:
>
> 6.23 Non-Constant Initializers
> ==============================
>
> As in standard C++ and ISO C99, the elements of an aggregate
> initializer for an automatic variable are not required to
> be constant expressions in GNU C. Here is an example of an
> initializer with run-time varying elements:
>
> foo (float f, float g)
> {
> float beat_freqs[2] = { f-g, f+g };
> /* ... */
> }
>
> C90 requires constant expression for all initializers. C99 permits
> non-constant expressions, but only for automatic variables.
The OP said he wanted non-constant initializers for global variables,
not for automatic variables.
--
"It used to be that the USA was pretty good at producing stuff teenaged
boys could lose a finger or two playing with." -- James Nicoll
[toc] | [prev] | [next] | [standalone]
Page 3 of 7 — ← Prev page 1 2 [3] 4 5 6 7 Next page →
Back to top | Article view | comp.arch
csiph-web