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.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,e91f674b5db5e2b2 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-09-17 00:53:04 PST Path: archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!paloalto-snf1.gtei.net!news.gtei.net!news.compaq.com!uunet!sac.uu.net!ash.uu.net!spool0901.news.uu.net!spool0900.news.uu.net!news0-alterdial.eu.uu.net!not-for-mail From: Juanma Barranquero Newsgroups: comp.lang.ada Subject: Assigning the value of a deferred constant? Date: Mon, 17 Sep 2001 09:53:03 +0200 Message-ID: References: <09Oo7.12082$mj6.1852826@news6-win.server.ntlworld.com> X-Newsreader: Forte Agent 1.8/32.548 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 62.22.27.143 X-Trace: news0-alterdial.eu.uu.net 1000713183 24943 62.22.27.143 Xref: archiver1.google.com comp.lang.ada:13112 Date: 2001-09-17T09:53:03+02:00 List-Id: On Mon, 17 Sep 2001 09:37:43 +0200, Juanma Barranquero wrote: >More or less. I've been doing: > > type Byte_Order is (Little_Endian, Big_Endian); > > Default_Byte_Order : Byte_Order; And vaguely related: Is there any way to declare a deferred constant and assign its value in the body of the declaring package, during elaboration? Something like: package Test is pragma Elaborate_Body; type Byte_Order is (Little_Endian, Big_Endian); Default_Byte_Order : constant Byte_Order; private Machine_Order : Byte_Order := Big_Endian; Default_Byte_Order : constant Byte_Order := Machine_Order; for Default_Byte_Order'Address use Machine_Order'Address; end Test; with Unchecked_Conversion; package body Test is type Word is mod 2 ** 32; subtype Chr4 is String (1..4); function UC is new Unchecked_Conversion(Word, Chr4); Test_Word : constant Word := 16#33323130#; Test_Chr4 : constant Chr4 := "0123"; begin if UC(Test_Word) = Test_Chr4 then Machine_Order := Little_Endian; else Machine_Order := Big_Endian; end if; end Test; That's not working (on Windows, with GNAT 3.13p), but I don't know if it should or shouldn't :( I know I could have different bodies for different architectures, or just substitute a function for the deferrent constant, doing instead: function Default_Byte_Order returns Byte_Order; pragma Inline(Default_Byte_Order); or something similar. But the question remains: Is there an easy and/or portable way to have a public constant view of a private variable? Thanks, /L/e/k/t/u