From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,e723b158fb4ad12e X-Google-Attributes: gid103376,public From: stt@houdini.camb.inmet.com (Tucker Taft) Subject: Re: Initialized global data Date: 1998/05/06 Message-ID: #1/1 X-Deja-AN: 350764919 Sender: news@inmet.camb.inmet.com (USENET news) References: <6iosc2$3mp@bgtnsc01.worldnet.att.net> X-Nntp-Posting-Host: houdini.camb.inmet.com Organization: Intermetrics, Inc. Newsgroups: comp.lang.ada Date: 1998-05-06T00:00:00+00:00 List-Id: 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