From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.5-pre1 (2020-06-20) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-1.9 required=3.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.5-pre1 Path: eternal-september.org!reader02.eternal-september.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Niklas Holsti Newsgroups: comp.lang.ada Subject: Re: Record initialisation question Date: Mon, 11 Jan 2021 22:58:57 +0200 Organization: Tidorum Ltd Message-ID: References: <5ff9779d$0$24281$426a74cc@news.free.fr> <5ffb311f$0$16185$426a74cc@news.free.fr> <5ffb7135$0$24247$426a74cc@news.free.fr> <5ffc8efd$0$8957$426a74cc@news.free.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net WRlwCtsEwQPUoqjYIny0eQbh6/u3wUagbkLLWl4Fm0n0kgzbeh Cancel-Lock: sha1:pFQiYitnFcXiTTG/VtQGqiI9ji8= User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:78.0) Gecko/20100101 Thunderbird/78.5.0 In-Reply-To: <5ffc8efd$0$8957$426a74cc@news.free.fr> Content-Language: en-US Xref: reader02.eternal-september.org comp.lang.ada:61100 List-Id: On 2021-01-11 19:46, DrPi wrote: > I added "pragma No_Elaboration_Code_All;" to my code and... all records > are rejected. > The boot data structure (in FLASH memory) is composed of several > records. They are linked by their addresses. When a record contains an > address, initializing it with a "non static number" value makes the > compiler complain (with No_Elaboration_Code_All set). Ah, too bad. The problem is that "static" in Ada means "known at compile time", while addresses, although static in execution, are generally not known until link time. A case where assembly language is more powerful :-( > I have to find a workaround. If addresses are the only problem, and you are in control of the flash memory lay-out, you might be able to define static Ada constant expressions that compute ("predict") the addresses of every boot data structure record. But those expressions would need to use the sizes of the records, I think, and unfortunately the 'Size of a record type is not a static expression (IIRC), and that may hold also for the GNAT-specific 'Max_Size_In_Storage_Units.