Article View: comp.std.c++
Article #937Re: Encouraging readonly memory (was ~const)
From: Ron Guilmette
Date: Sun, 10 Mar 1991 03:12
Date: Sun, 10 Mar 1991 03:12
51 lines
2421 bytes
2421 bytes
In article <71044@microsoft.UUCP+ jimad@microsoft.UUCP (Jim ADCOCK) writes:
+In article <4200@lupine.NCD.COM> rfg@NCD.COM (Ron Guilmette) writes:
+|Hummm... I'll bet you would like to see the data object called `array' in
+|the following example be able to go into ROM. Interestingly, I think
+|that the semantics currently defined for the initialization of local
+|static objects might effectively prohibit such treatment.
+|
+| void foobar ()
+| {
+| static const char array[] = "Hello world.\n";
+|
+| // ...
+| }
+|
+|This is probably not the best example I could have cooked up, but if you
+|read the bottom half of page 92 in the ARM, you may see the problem that
+|I'm getting at.
+
+I'm not sure I do. I don't see any problems with you example.
+Perhaps you can clarify?...
Well, perhaps my idle theorizing about how to ROM-ize a C++ program
is a bit half-baked, but here goes...
One possible approach to ROM-izing a C++ program would be to actually
*run* the program until just before it is about to enter main() and
then freeze the image of all of the code and all of the initialized
(and const) file-scope objects at that instant in time and then burn
the PROMS based upon that image.
That way, if you had some class C (which required construction) and
some file-scope object declaration like:
const C c_object (9.9, "hello world");
The "initial" values for these could go into ROM also.
Unfortunately, this scheme leaves out the example from my previous
posting (shown above). Try to imagine the declaration of `array'
being something like this instead:
static const C local_c_object (9.9 "hello");
This will not have been "elaborated" at the "image freeze time" so
you won't be able to put this particular object into ROM.
--
// Ron Guilmette - C++ Entomologist
// Internet: rfg@ncd.com uucp: ...uunet!lupine!rfg
// New motto: If it ain't broke, try using a bigger hammer.
Technical Details
Message-ID:
<4330@lupine.NCD.COM>Path:
arc1-ca.pugleaf.net!utzoo!news-server.csri.toronto.edu!rutgers!usc!elroy.jpl.nasa.gov!decwrl!infopiz!lupine!rfgReferences:
<BRUCEC.91Feb21132333@phoebus.labs.tek.com+ <4200@lupine.NCD.COM> <71044@microsoft.UUCP>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!news-server.csri.toronto.edu!rutgers!usc!elroy.jpl.nasa.gov!decwrl!infopiz!lupine!rfg From: rfg@NCD.COM (Ron Guilmette) Newsgroups: comp.std.c++ Subject: Re: Encouraging readonly memory (was ~const) Message-ID: <4330@lupine.NCD.COM> Date: 10 Mar 91 03:12:11 GMT References: <BRUCEC.91Feb21132333@phoebus.labs.tek.com+ <4200@lupine.NCD.COM> <71044@microsoft.UUCP> Organization: Network Computing Devices, Inc., Mt. View, CA Lines: 51