comp.lang.ada
 help / color / mirror / Atom feed
From: "Michael Erdmann" <boavista@berlin.snafu.de>
Subject: Re: Q: How to do memory access with gnat - OS.ADS (0/1)
Date: 1997/07/20
Date: 1997-07-20T00:00:00+00:00	[thread overview]
Message-ID: <zmdoaiacwomqcsz.pminews@boavista.berlin.snafu.de> (raw)
In-Reply-To: EDMCGE.79A.0.-s@inmet.camb.inmet.com


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 <arbitrary computation>;
:>  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!







  parent reply	other threads:[~1997-07-20  0:00 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-07-20  0:00 Q: How to do memory access with gnat Michael Erdmann
1997-07-20  0:00 ` Tucker Taft
1997-07-20  0:00   ` Q: How to do memory access with gnat - OS.ADS (1/1) Michael Erdmann
1997-07-20  0:00   ` Michael Erdmann [this message]
1997-07-20  0:00   ` Q: How to do memory access with gnat - os.ADB (0/1) Michael Erdmann
1997-07-20  0:00 ` Q: How to do memory access with gnat Samuel Tardieu
1997-07-20  0:00   ` Michael Erdmann
1997-07-22  0:00 ` Michael Erdmann
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox