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,18f3577df8d90927 X-Google-Attributes: gid103376,public From: stt@houdini.camb.inmet.com (Tucker Taft) Subject: Re: Q: How to do memory access with gnat Date: 1997/07/20 Message-ID: #1/1 X-Deja-AN: 257834746 Sender: news@inmet.camb.inmet.com (USENET news) X-Nntp-Posting-Host: houdini.camb.inmet.com References: Organization: Intermetrics, Inc. Newsgroups: comp.lang.ada Date: 1997-07-20T00:00:00+00:00 List-Id: Michael Erdmann (boavista@berlin.snafu.de) wrote: : i like to do something like this in Ada95 (excuse the C-example): : typedef struct { ..,other_data; char data[1]; } Msg_data; : Msg_Data *shared; : // get some memory from the system : DosGetSharedMemory( ..., &shared... ) : // copy data into shared memory : for( i ,,,, ) : shared->data[i] := some_data[i]; : In Ada95 i am not able to copy data from an Ada object into a some external : memory. : Any idea ? 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) := ... 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, or by passing its 'Address to some external routine. type Msg_Data_Ptr is access all Msg_Data; Shared : Msg_Data_Ptr; begin DosGetSharedMemory(..., Shared'Address, ...); Shared.data(I) := ... -- -Tucker Taft stt@inmet.com http://www.inmet.com/~stt/ Intermetrics, Inc. Burlington, MA USA