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=0.2 required=5.0 tests=BAYES_00,INVALID_MSGID, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,18f3577df8d90927 X-Google-Attributes: gid103376,public From: "Michael Erdmann" Subject: Re: Q: How to do memory access with gnat - os.ADB (0/1) Date: 1997/07/20 Message-ID: #1/1 X-Deja-AN: 257850263 References: Organization: Unlimited Surprise Systems, Berlin Reply-To: "Michael Erdmann" Newsgroups: comp.lang.ada Date: 1997-07-20T00:00:00+00:00 List-Id: On Sun, 20 Jul 1997 13:07:26 GMT, Tucker Taft wrote: :>Michael Erdmann (boavista@berlin.snafu.de) wrote: ::> :>You can use an address clause to associate an Ada name with a given :>address. E.g.: :> Shared : Msg_Data; :> for Shared'Address use ; :> begin :> Shared.data(I) := ... The important point is this assignment here. The example is from a simple message passing system where the size of the data array message is not known. The message record is defined like this: type Message_Record( Record_Size : Integer ) is record Nbr_Of_Bytes : Integer := Record_Size; data : DataBuffer(1..Record_Size); end record; The Problem is when i am doing it like this; RC := DosAllocateShared( .... shared_data ) Msg := To_Message( shared_data ); -- convert to access to Message_Record Msg.Nbr_Of_Bytes := ,,,,,; Msg.data(1,,Nbr_Of_Bytes) := data(1....) a contraint error is generated in the last assignment. :> :>Alternatively, the most direct analogy to the C approach is to declare :>an access type, and initialize a variable of the type using :>unchecked_conversion or the Address_To_Access_Conversion generic, I have done this. In order to by pass the problem with the array above i thought about a procedure which would allow to store data relative to a base address. The problem is i am not able to add an integer offset to an address, because it is not possible to convert from Integer to Stoarge_Offset from System.Storage_Elements. >or by :>passing its 'Address to some external routine. I hope i dont need to do it!