From: "David Botton" <David@Botton.com>
Subject: Re: A copy question....
Date: Tue, 16 Oct 2001 21:14:11 -0400
Date: 2001-10-16T21:14:11-04:00 [thread overview]
Message-ID: <tspmr59b61e391@corp.supernews.com> (raw)
In-Reply-To: t74z7.24114$gT6.15011939@news1.rdc1.sfba.home.com
I was showing my "favorite" method. The use of the 'Img was part of the test
driver. It is a convenience that I am surprised has not been adopted by
other vendors.
I admit that since most of my Ada programming is with GNAT, I get lazy about
portability to other compilers.
Here is a more universal version:
with Ada.Text_IO; use Ada.Text_IO;
with System.Address_To_Access_Conversions;
with System;
with Interfaces;
procedure Block is
type My_Array is array (Integer range <>) of Interfaces.Unsigned_32;
Stuff_In_Memory : My_Array (1 .. 200) := (others => 999);
Address : System.Address := Stuff_In_Memory (1)'Address;
Data_Length : Natural := Stuff_In_Memory'Length;
-- Assuming of Unsigned_32s
type The_Array is new My_Array (1 .. Data_Length);
pragma Pack (The_Array);
package Array_Copier is
new System.Address_To_Access_Conversions (The_Array);
Copied_Array : The_Array := Array_Copier.To_Pointer (Address).all;
begin
for N in Copied_Array'Range loop
Put_Line (Interfaces.Unsigned_32'Image (Copied_Array (N)));
end loop;
end Block;
<tmoran@acm.org> wrote in message
news:t74z7.24114$gT6.15011939@news1.rdc1.sfba.home.com...
> Speaking of portability,
> > function To_Pointer_To_The_Array is
> > new Ada.Unchecked_Conversion (System.Address, Pointer_To_The_Array);
> is not portable, while
> package System.Address_To_Access_Conversions
> is specifically designed to do what you want.
> > Put_Line (Copied_Array (N)'Img);
> The 'Img attribute is a "vendor special", 'Image would be portable.
next prev parent reply other threads:[~2001-10-17 1:14 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-10-15 10:40 A copy question Zebylon
2001-10-15 11:21 ` Dale Stanbrough
2001-10-15 11:30 ` Dale Stanbrough
2001-10-15 11:59 ` Petter Fryklund
2001-10-15 21:04 ` Dale Stanbrough
2001-10-16 2:34 ` Jeffrey Carter
2001-10-16 11:15 ` Dale Stanbrough
2001-10-15 13:38 ` Ted Dennison
2001-10-15 13:30 ` Mark Doherty
2001-10-15 17:00 ` tmoran
2001-10-16 10:09 ` Mark Doherty
2001-10-17 0:18 ` tmoran
2001-10-17 1:14 ` David Botton [this message]
2001-10-16 23:00 ` David Botton
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox