comp.lang.ada
 help / color / mirror / Atom feed
From: stt@houdini.camb.inmet.com (Tucker Taft)
Subject: Re: Initialized global data
Date: 1998/05/06
Date: 1998-05-06T00:00:00+00:00	[thread overview]
Message-ID: <EsJEEA.HCJ.0.-s@inmet.camb.inmet.com> (raw)
In-Reply-To: 6iosc2$3mp@bgtnsc01.worldnet.att.net


Kevin Wells (wellsk@worldnet.att.net) wrote:

: When specifying data in an Ada package that is pre-initialized such as
: ----------------------------------------
: package Generate_Matrix is
:   Scale_Factor : float := 10.903;
:   .
: end Generate_Matrix; -- spec
: ----------------------------------------

: 1. Is it normal for the compiler to generate code that sets the value in
: memory
:     (that gets executed when the runtime system is initialized)?

That of course depends on the implementation.  I would say
that most "good" implementations support static initialization
of variables like the one above.  If the initial value is non-static,
then of course run-time code is required.

: 2. Is there a way to get around this?

Choose a different implementation.  What are the host and target
of interest?  I suspect comp.lang.ada readers could inform you
of compilers that do what you want.

: I am trying to create pre-initialized data arrays in memory such as
: ----------------------------------------
: type Array_Type is array (1 .. 5) of integer;
: Small_Array : Array_Type := (1, 10, 5, 9, -50);
: ----------------------------------------
: but the compiler generates a bunch of code to set those 5 memory
: locations.
: (The actual code generated is about 3 to 5 times the size of the data
: area
: of the array). 
: ...
: Does anyone have any ideas or suggestions about doing this that fits
: within
: Ada's elegant realm of development (No external overlays) and allows the

: actual preinitialized data (without the code) to be saved in the final
: executable?

As mentioned above, it would be useful to know the host and target.
Also, it would be important to see the exact code being used.
If the upper bound of the array is dynamic, or if this table
is in the main subprogram rather than in a package, you might
end up with the problem you are seeing, even with a "good" implementation.

One thing that will certainly help increase the likelihood of
static initialization is to use "constant Array_Type" rather than
simply "Array_Type" if the array is not being altered after initialization.

: Thanks much,
: Kevin Wells, Software Engineer, Boeing
: wellsk@netcom.com

--
-Tucker Taft   stt@inmet.com   http://www.inmet.com/~stt/
Intermetrics, Inc.  Burlington, MA  USA




  parent reply	other threads:[~1998-05-06  0:00 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-05-05  0:00 Initialized global data Kevin Wells
1998-05-05  0:00 ` A little more data Kevin Wells
1998-05-06  0:00   ` Stephen Leake
1998-05-06  0:00 ` Initialized global data John English
1998-05-06  0:00 ` Anonymous
1998-05-08  0:00   ` Simon Wright
1998-05-08  0:00     ` Tucker Taft
1998-05-09  0:00       ` Simon Wright
1998-05-10  0:00         ` Robert Dewar
1998-05-11  0:00           ` Simon Wright
1998-05-11  0:00             ` Matthew Heaney
1998-05-06  0:00 ` Tucker Taft [this message]
1998-05-09  0:00 ` Niklas Holsti
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox